c_edit.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. {extend name="common/base"/}
  2. {block name="style"}
  3. <style>
  4. .fujian {
  5. display: flex;
  6. }
  7. .fujianimg img {
  8. height: 9vh !important;
  9. }
  10. .forleft {
  11. text-align: left !important;
  12. }
  13. .form-title {
  14. background-color: rgb(241, 241, 241);
  15. color: rgb(95, 95, 95);
  16. border-color: rgb(241, 241, 241);
  17. text-align: center;
  18. border-color: #e2e2e2;
  19. }
  20. .filelist{
  21. width: 100%;
  22. overflow: auto;
  23. justify-content:flex-start;
  24. align-content: space-between;
  25. flex-direction: column-reverse;
  26. flex-wrap: wrap;
  27. display: flex;
  28. }
  29. .filelist li{
  30. padding: 0.5vw 0.8vw 0.5vw 0.8vw;
  31. white-space: nowrap;
  32. overflow: hidden;
  33. text-overflow: ellipsis;
  34. display: inline-block;
  35. border-right: 1px solid #e2e2e2;
  36. float: left;
  37. }
  38. .filelist p{
  39. margin: 3px 0 5px 0;
  40. width: 7vw;
  41. overflow: hidden;
  42. text-overflow: ellipsis;
  43. text-align: center;
  44. }
  45. .footer{
  46. display: none;
  47. }
  48. #filesBox2 li{
  49. padding: 0.5vw 0.8vw 0.5vw 0.8vw;
  50. white-space: nowrap;
  51. overflow: hidden;
  52. text-overflow: ellipsis;
  53. display: inline-block;
  54. border-right: 1px solid #e2e2e2;
  55. float: left;
  56. }
  57. .layui-table th{
  58. text-align: center !important;
  59. font-weight: 500;
  60. }
  61. .layui-anim dd{
  62. text-align: left;
  63. }
  64. .layui-th-gray{
  65. background-color: rgb(241, 241, 241);
  66. }
  67. .layui-table th{
  68. border-color: #e2e2e2
  69. }
  70. .layui-btn-group span:last-child{
  71. display: none;
  72. }
  73. </style>
  74. {/block}
  75. <!-- 主体 -->
  76. {block name="body"}
  77. <div class="p-3">
  78. <table class="layui-hide" id="appropriation_add" lay-filter="appropriation_add"></table>
  79. <form class="layui-form p-4">
  80. <table class="layui-table layui-table-form">
  81. <tr>
  82. <th class="layui-th-gray" style="height:36px;">委托单位</th>
  83. <th colspan="5">
  84. {$detail.entrust_unit_name}
  85. </th>
  86. <th class="layui-th-gray">是否开票</th>
  87. <th colspan="2">
  88. {if $detail.invoicing_whether!=0}是{/elseif $detail.invoicing_whether==0}}否{/else}未拨款{/if}
  89. </th>
  90. </tr>
  91. <tr>
  92. <th class="layui-th-gray">发票编号</th>
  93. <th colspan="2">
  94. <input type="text" name="invoicing_num" readonly autocomplete="off" placeholder="请输入发票编号" class="layui-input" value="{$detail.invoicing_num}">
  95. </th>
  96. <th class="layui-th-gray">发票类型</th>
  97. <th colspan="2">
  98. <select name="invoice_type" lay-verify="required" disabled="disabled">
  99. <option value="0"></option>
  100. <option value="1" {if $detail.invoice_type==1}selected{/if}>普通发票</option>
  101. <option value="2" {if $detail.invoice_type==2}selected{/if}>专用发票</option>
  102. <option value="3" {if $detail.invoice_type==3}selected{/if}>电子普票</option>
  103. <option value="4" {if $detail.invoice_type==4}selected{/if}>电子专票</option>
  104. </select>
  105. </th>
  106. <th class="layui-th-gray">发票金额</th>
  107. <th colspan="2">
  108. <input type="text" name="invoicing_amount" readonly autocomplete="off" placeholder="请输入发票金额" class="layui-input" value="{$detail.invoicing_amount}">
  109. </th>
  110. </tr>
  111. <tr>
  112. <th colspan="9" class="forleft" style="text-align:left !important;">相关附件
  113. </th>
  114. </tr>
  115. <tr>
  116. <th colspan="9" class="fujianimg" style="padding: 9px 0;">
  117. <div id="filesBox2">
  118. <div class="filelist" id="filesBigBox">
  119. <ul id="filesBox" style="height: 16.2vh;">
  120. {:fileCard($file_array)}
  121. </ul>
  122. </div>
  123. {empty name="$file_array" }
  124. <div class="layui-data-none" >暂无附件</div>
  125. {/empty}
  126. </div>
  127. </th>
  128. </tr>
  129. </table>
  130. <div class="pt-3">
  131. <input type="hidden" name="id" value="{$id}">
  132. <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="webform">通过</button>
  133. <button type="button" class="layui-btn layui-btn-danger" lay-submit lay-filter="save">拒绝</button>
  134. </div>
  135. </form>
  136. </div>
  137. {/block}
  138. <!-- /主体 -->
  139. <!-- 脚本 -->
  140. {block name="script"}
  141. <script>
  142. var moduleInit = ['tool', 'oaTool'];
  143. function gouguInit() {
  144. var form = layui.form, tool = layui.tool, oaTool = layui.oaTool, table = layui.table, layer = layui.layer;
  145. var file_ids = [];
  146. var project_ids = [];
  147. layui.pageTable = table.render({
  148. elem: '#appropriation_add',
  149. id: "appropriation_add",
  150. title: '造价项目列表',
  151. url: '/admin/project.appropriation/c_edit?id=' + '{$id}',
  152. totalRow: true,
  153. cellMinWidth: 150,
  154. cols: [
  155. [{
  156. fixed: 'left',
  157. field: 'id',
  158. title: '编号',
  159. align: 'center',
  160. width: 80,
  161. totalRowText: "合计"
  162. }, {
  163. field: 'project_name',
  164. title: '项目名称',
  165. align: 'center',
  166. }, {
  167. field: 'sent_review_cost',
  168. title: '送审服务费',
  169. align: 'center',
  170. totalRow: true,
  171. }, {
  172. field: 'appropriation_amount',
  173. title: '请款金额',
  174. align: 'center',
  175. totalRow: true,
  176. }, {
  177. field: 'refund_amount',
  178. title: '回款金额',
  179. align: 'center',
  180. totalRow: true,
  181. // edit: true
  182. }
  183. ]
  184. ],
  185. css: [
  186. // 对开启了编辑的单元格追加样式
  187. '.layui-table-view th[data-edit]{color: #16B777;}'
  188. ].join(''),
  189. });
  190. table.on('edit(appropriation_add)', function (obj) {
  191. var field = obj.field; // 得到修改的字段
  192. var value = obj.value // 得到修改后的值
  193. var data = obj.data // 得到所在行所有键值
  194. var id = data.id;
  195. // 值的校验
  196. if (value.replace(/\s/g, '') === '') {
  197. layer.tips('值不能为空', this, {tips: 1});
  198. return obj.reedit(); // 重新编辑 -- v2.8.0 新增
  199. }
  200. let callback = function (e) {
  201. let sent_review_amount = 0;
  202. let appropriation_amount = 0;
  203. let refund_amount = 0;
  204. layui.each(layui.table.cache['appropriation_add'], function (index, row) {
  205. sent_review_amount += row.sent_review_amount;
  206. appropriation_amount += row.appropriation_amount;
  207. refund_amount += row.refund_amount
  208. });
  209. // $(".layui-table-total th[data-field=sent_review_amount]").html(sent_review_amount);
  210. // $(".layui-table-total th[data-field=appropriation_amount]").html(appropriation_amount);
  211. // $(".layui-table-total th[data-field=refund_amount]").html(`<div className="layui-table-cell laytable-cell-1-0-4" align="center">${refund_amount}</div>`);
  212. layui.pageTable.reload();
  213. layer.msg(e.msg)
  214. }
  215. tool.post("edit", {refund_amount:data.refund_amount}, callback)
  216. });
  217. let a = 1;
  218. form.on('submit(webform)', function (data) {
  219. let refund_amount = 0;
  220. layui.each(layui.table.cache['appropriation_add'], function (index, row) {
  221. refund_amount += Number(row.refund_amount)
  222. });
  223. data.field.refund_amount = refund_amount;
  224. delete data.field.file;
  225. console.log(data);
  226. if(a){
  227. let callback = function (e) {
  228. layer.msg(e.msg)
  229. parent.location.reload();
  230. if (e.code == 0) {
  231. tool.sideClose(1000);
  232. a = 1
  233. }
  234. }
  235. layer.confirm("确认是否审批通过?", function (index) {
  236. tool.post("/admin/project.appropriation/cc_edit", data.field, callback)
  237. a = 0
  238. })
  239. }
  240. return false;
  241. });
  242. form.on('submit(save)', function (data) {
  243. if(a){
  244. let callback = function (e) {
  245. layer.msg(e.msg)
  246. parent.location.reload();
  247. if (e.code == 0) {
  248. tool.sideClose(1000);
  249. a = 1
  250. }
  251. }
  252. layer.prompt({
  253. title: '请输入<span style="color: red">拒绝</span>原因',
  254. formType: 2,
  255. area: ['35vw', '15vw']
  256. }, function (text, index) {
  257. if (text == '') {
  258. layer.msg('请先完善拒绝原因');
  259. return false;
  260. } else {
  261. data.field.reason = text;
  262. tool.post("/admin/project.appropriation/disagree", data.field, callback)
  263. a = 0
  264. }
  265. })
  266. }
  267. return false;
  268. });
  269. function fileCard(item) {
  270. var host = window.location.host;
  271. var li = '';
  272. if (item.length > 0) {
  273. for (var a = 0; a < item.length; a++) {
  274. let image = ['jpg', 'jpeg', 'png', 'gif'];
  275. let doc = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'zip', 'rar', '7z'];
  276. // let down = '<a href="'+item[a].filepath+'" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="'+item[a].name+'">下载</a>';
  277. let down = '<a href="'+ item[a]['filepath'] + '" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="' + item[a]['name'] + '">预览</a>';
  278. // 判断元素是否在数组中
  279. let path = '/static/home/images/icon/file.png';
  280. if (image.includes(item[a].fileext)) {
  281. path = item[a].filepath;
  282. down = '<span data-href="' + item[a].filepath + '" class="layui-btn layui-btn-xs layui-btn-normal file-view-img">预览</span>';
  283. } else if (doc.includes(item[a].fileext)) {
  284. path = '/static/home/images/icon/' + item[a].fileext + '.png';
  285. }
  286. if (item[a].fileext == 'pdf') {
  287. down = '<span data-href="' + item[a].filepath + '" class="layui-btn layui-btn-xs layui-btn-normal file-view-pdf">预览</span>';
  288. }
  289. li += '<li id="' + item[a].id + '" data-id="' + item[a].id + '" data-title="' + item[a].name + '" data-ext="' + item[a].fileext + '"><img src="' + path + '" alt="' + item[a].filename +
  290. '" style="object-fit: contain;" class="file-item"><p title="' + item[a].name + '">' + item[a].name +
  291. '</p><div class="layui-btn-group">' + down +
  292. '<span class="layui-btn layui-btn-xs layui-btn-danger file-del">删除</span></div></li>';
  293. }
  294. return li;
  295. }
  296. }
  297. $('#filesBox').on('click', '.file-del', function () {
  298. let id = $(this).parent().parent().data('id');
  299. layer.confirm('确定要删除该文件吗?', {icon: 3, title: '提示'}, function () {
  300. let callback = function (e){
  301. layer.closeAll();
  302. if (e.hasOwnProperty("msg")) {
  303. layer.msg(e.msg);
  304. }
  305. if(e.code==0){
  306. var index = file_ids.indexOf(id);
  307. if (index > -1) {
  308. file_ids.splice(index, 1);
  309. }
  310. if (file_ids.length == 0) {
  311. $("#filesBox").append('<div id="nofile" class="layui-data-none" >暂无附件</div>');
  312. }
  313. $("#" + id).remove();
  314. }
  315. }
  316. tool.delete("/admin/project.api/delete_file", {id: id}, callback)
  317. });
  318. })
  319. oaTool.addFile({
  320. type: 1,
  321. isSave: true,
  322. ajaxSave: function (res) {
  323. if(file_ids.length<1){
  324. console.log(file_ids.length)
  325. let callback = function (e) {
  326. if (e.hasOwnProperty("msg")) {
  327. layer.msg(e.msg);
  328. } else {
  329. layer.msg('上传成功!')
  330. }
  331. if (e[0].id) {
  332. file_ids.push(e[0].id)
  333. $('#nofile').remove();
  334. $("#filesBox").append(fileCard(e));
  335. }
  336. }
  337. tool.post("/admin/project.api/add_file", {
  338. 'file_id': res.data.id,
  339. }, callback);
  340. }else {
  341. layer.msg('仅可上传一份文件!')
  342. }
  343. }
  344. });
  345. }
  346. </script>
  347. <script>
  348. // 获取具有指定 ID 的 <ul> 元素
  349. var ulElement = document.getElementById("filesBox");
  350. // 检查 <ul> 元素的子元素数量
  351. if (ulElement.children.length === 0) {
  352. // 如果子元素数量为 0,隐藏 <ul> 元素
  353. ulElement.style.display = "none";
  354. }
  355. </script>
  356. {/block}
  357. <!-- /脚本 -->