edit_company.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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. .forleft {
  71. text-align: left !important;
  72. }
  73. .layui-btn-group span:last-child{
  74. display: none;
  75. }
  76. </style>
  77. {/block}
  78. <!-- 主体 -->
  79. {block name="body"}
  80. <div class="p-3">
  81. <table class="layui-hide" id="appropriation_add" lay-filter="appropriation_add"></table>
  82. <form class="layui-form p-4">
  83. <table class="layui-table layui-table-form">
  84. <tr>
  85. <th class="layui-th-gray">委托单位</th>
  86. <th colspan="5" style="text-align:left !important;padding-left:2.5vw;">
  87. {$detail.entrust_unit_name}
  88. <input type="hidden" name="entrust_unit" value="{$detail.entrust_unit}">
  89. </th>
  90. <th class="layui-th-gray">是否开票</th>
  91. <th colspan="2">
  92. <input type="radio" name="invoice_status" value="1" title="是" {if $detail.invoice_status==1}checked{/if}>
  93. <input type="radio" name="invoice_status" value="0" title="否" {if $detail.invoice_status==0}checked{/if}>
  94. </th>
  95. </tr>
  96. <tr>
  97. <th class="layui-th-gray">发票编号</th>
  98. <th colspan="2">
  99. <input type="text" name="invoicing_num" autocomplete="off" placeholder="请输入发票编号" class="layui-input" value="{$detail.invoicing_num}">
  100. </th>
  101. <th class="layui-th-gray">发票类型</th>
  102. <th colspan="2">
  103. <select name="invoice_type" lay-verify="required" >
  104. <option value="0"></option>
  105. <option value="1" {if $detail.invoice_type==1}selected{/if}>普通发票</option>
  106. <option value="2" {if $detail.invoice_type==2}selected{/if}>专用发票</option>
  107. <option value="3" {if $detail.invoice_type==3}selected{/if}>电子普票</option>
  108. <option value="4" {if $detail.invoice_type==4}selected{/if}>电子专票</option>
  109. </select>
  110. </th>
  111. <th class="layui-th-gray">发票金额</th>
  112. <th colspan="2">
  113. <input type="text" name="invoicing_amount" autocomplete="off" placeholder="请输入发票金额" class="layui-input" value="{$detail.invoicing_amount}">
  114. </th>
  115. </tr>
  116. {if $detail.status==0||$detail.status==-2}
  117. <tr>
  118. <th class="layui-th-gray">一级审核人 <font style="color: red !important;">*</font></th>
  119. <th colspan="2">
  120. <input type="text" name="first_name" lay-verify="required" lay-reqText="请输入一级审核人" placeholder="请输入一级审核人" class="layui-input picker-one" value="">
  121. <input type="hidden" name="first" value="">
  122. </th>
  123. <th class="layui-th-gray">二级审核人</th>
  124. <th colspan="2">
  125. <input type="text" name="second_name" placeholder="请输入二级审核人,可空" class="layui-input picker-one" value="">
  126. <input type="hidden" name="second" value="">
  127. </th>
  128. <th class="layui-th-gray">三级审核人</th>
  129. <th colspan="2">
  130. <input type="text" name="third_name" placeholder="请输入三级审核人,可空" class="layui-input picker-one" value="">
  131. <input type="hidden" name="third" value="">
  132. </th>
  133. </tr>
  134. {/if}
  135. <tr>
  136. <th colspan="9" class="forleft" style="text-align: left !important;">相关附件
  137. <!--<button class="layui-btn layui-btn-xs layui-btn-danger" style="float: right;" type="button" id="uploadBtn">上传附件</button>-->
  138. </th>
  139. </tr>
  140. <tr>
  141. <th colspan="9" class="fujianimg" style="padding: 9px 0;">
  142. <div id="filesBox2">
  143. <div class="filelist" id="filesBigBox">
  144. <ul id="filesBox" style="height: 16.2vh;">
  145. {:fileCard($file_array)}
  146. </ul>
  147. </div>
  148. {empty name="$file_array" }
  149. <div class="layui-data-none" >暂无附件</div>
  150. {/empty}
  151. </div>
  152. </th>
  153. </tr>
  154. </table>
  155. <div class="pt-3">
  156. <input type="hidden" name="id" value="{$id}">
  157. <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="save">保存</button>
  158. {if $detail.status==0||$detail.status==-2}
  159. <button type="button" class="layui-btn layui-btn-danger" lay-submit lay-filter="webform">提交审核</button>
  160. {/if}
  161. </div>
  162. </form>
  163. </div>
  164. <script type="text/html" id="toolbarDemo">
  165. {if $detail.status==0||$detail.status==-2}
  166. <div class="layui-btn-container">
  167. <span class="layui-btn layui-btn-sm" id="project-picker" data-title="添加造价项目">+ 添加造价项目</span>
  168. </div>
  169. {/if}
  170. </script>
  171. <script type="text/html" id="barDemo">
  172. <div class="layui-btn-container">
  173. {if $detail.status==0}
  174. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  175. {/if}
  176. </div>
  177. </script>
  178. {/block}
  179. <!-- /主体 -->
  180. <!-- 脚本 -->
  181. {block name="script"}
  182. <script>
  183. var moduleInit = ['tool', 'oaTool', 'employeepicker'];
  184. function gouguInit() {
  185. var form = layui.form, tool = layui.tool, oaTool = layui.oaTool, table = layui.table, layer = layui.layer , employeepicker = layui.employeepicker;
  186. var file_ids = [];
  187. var project_ids = [];
  188. var uid = {$id};
  189. layui.pageTable = table.render({
  190. elem: '#appropriation_add',
  191. id: "appropriation_add",
  192. toolbar: '#toolbarDemo',
  193. title: '造价项目列表',
  194. url: '/admin/project.appropriation/c_edit?id=' + '{$id}',
  195. totalRow: true,
  196. cellMinWidth: 150,
  197. cols: [
  198. [{
  199. fixed: 'left',
  200. field: 'id',
  201. title: '编号',
  202. align: 'center',
  203. width: 80,
  204. totalRowText: "合计"
  205. }, {
  206. field: 'project_name',
  207. title: '项目名称',
  208. align: 'center',
  209. }, {
  210. field: 'sent_review_cost',
  211. title: '送审服务费',
  212. align: 'center',
  213. totalRow: true,
  214. }, {
  215. field: 'appropriation_amount',
  216. title: '请款金额',
  217. align: 'center',
  218. totalRow: true,
  219. // edit: true
  220. }, {
  221. field: 'refund_amount',
  222. title: '回款金额',
  223. align: 'center',
  224. totalRow: true,
  225. edit: true
  226. // edit: true
  227. },{
  228. fixed: 'right',
  229. field: 'right',
  230. title: '操作',
  231. toolbar: '#barDemo',
  232. width: 136,
  233. align: 'center'
  234. }
  235. ]
  236. ],
  237. css: [
  238. // 对开启了编辑的单元格追加样式
  239. '.layui-table-view th[data-edit]{color: #16B777;}'
  240. ].join(''),
  241. });
  242. table.on('edit(appropriation_add)', function (obj) {
  243. var field = obj.field; // 得到修改的字段
  244. var value = obj.value // 得到修改后的值
  245. var data = obj.data // 得到所在行所有键值
  246. var id = data.id;
  247. // 值的校验
  248. if (value.replace(/\s/g, '') === '') {
  249. layer.tips('值不能为空', this, {tips: 1});
  250. return obj.reedit(); // 重新编辑 -- v2.8.0 新增
  251. }
  252. let callback = function (e) {
  253. let sent_review_amount = 0;
  254. let appropriation_amount = 0;
  255. // layui.each(layui.table.cache['appropriation_add'], function (index, row) {
  256. //
  257. // sent_review_amount += row.sent_review_amount;
  258. // appropriation_amount += row.appropriation_amount;
  259. // });
  260. // $(".layui-table-total th[data-field=sent_review_amount]").append(sent_review_amount);
  261. // $(".layui-table-total th[data-field=appropriation_amount]").append(appropriation_amount);
  262. layui.pageTable.reload();
  263. layer.msg(e.msg)
  264. }
  265. tool.post("edit", {refund_amount:data.refund_amount}, callback)
  266. });
  267. table.on('tool(appropriation_add)', function (obj) {
  268. var data = obj.data;
  269. if (obj.event === 'del') {
  270. let callback = function (e) {
  271. layer.msg(e.msg)
  272. layui.pageTable.reload();
  273. }
  274. tool.post("/admin/project.appropriation/del_project", {id: data.id}, callback)
  275. }
  276. })
  277. let a = 1;
  278. form.on('submit(save)', function (data) {
  279. data.field.project_ids = project_ids;
  280. data.field.file_ids = file_ids;
  281. let refund_amount = 0,appropriation_amount = 0;
  282. layui.each(layui.table.cache['appropriation_add'], function (index, row) {
  283. appropriation_amount += Number(row.appropriation_amount)
  284. refund_amount += Number(row.refund_amount)
  285. });
  286. data.field.appropriation_amount = appropriation_amount;
  287. data.field.refund_amount = refund_amount;
  288. delete data.field.file;
  289. console.log(data);
  290. if(a){
  291. let callback = function (e) {
  292. layer.msg(e.msg)
  293. parent.location.reload();
  294. if (e.code == 0) {
  295. tool.sideClose(1000);
  296. a = 1
  297. }
  298. }
  299. tool.post("/admin/project.appropriation/save", data.field, callback)
  300. }
  301. a = 0
  302. return false;
  303. });
  304. form.on('submit(webform)', function (data) {
  305. data.field.project_ids = project_ids;
  306. data.field.file_ids = file_ids;
  307. let refund_amount = 0,appropriation_amount = 0;
  308. layui.each(layui.table.cache['appropriation_add'], function (index, row) {
  309. appropriation_amount += Number(row.appropriation_amount)
  310. refund_amount += Number(row.refund_amount)
  311. });
  312. data.field.appropriation_amount = appropriation_amount;
  313. data.field.refund_amount = refund_amount;
  314. if(a){
  315. let callback = function (e) {
  316. layer.msg(e.msg)
  317. parent.location.reload();
  318. if (e.code == 0) {
  319. tool.sideClose(1000);
  320. a = 1
  321. }
  322. }
  323. tool.post("/admin/project.appropriation/add", data.field, callback)
  324. }
  325. a = 0
  326. return false;
  327. });
  328. $('body').on('click', '#project-picker', function () {
  329. let callback = function (e) {
  330. layer.msg(e.msg);
  331. layui.pageTable.reload();
  332. }
  333. let call = function (e) {
  334. var aa = $('[name="entrust_unit"]').val();
  335. if (aa !== "") {
  336. if (aa !== e.entrust_unit) {
  337. layer.msg("不可添加不同委托单位")
  338. setTimeout(function () {
  339. return;
  340. },2000)
  341. }else{
  342. var posthata = {uid:uid,project_id: e.id, project_name: e.project_name,sent_review_amount:e.sent_review_cost,appropriation_amount:e.sent_review_cost};
  343. tool.post("/admin/project.appropriation/add_project", posthata, callback);
  344. $('[name="entrust_unit_name"]').val(e.entrust_unit_name);
  345. $('[name="entrust_unit"]').val(e.entrust_unit);
  346. }
  347. }
  348. }
  349. oaTool.ProjectPicker(call);
  350. })
  351. function fileCard(item) {
  352. var host = window.location.host;
  353. var li = '';
  354. if (item.length > 0) {
  355. for (var a = 0; a < item.length; a++) {
  356. let image = ['jpg', 'jpeg', 'png', 'gif'];
  357. let doc = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'zip', 'rar', '7z'];
  358. // let down = '<a href="'+item[a].filepath+'" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="'+item[a].name+'">下载</a>';
  359. let down = '<a href="' + item[a]['filepath'] + '" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="' + item[a]['name'] + '">预览</a>';
  360. // 判断元素是否在数组中
  361. let path = '/static/home/images/icon/file.png';
  362. if (image.includes(item[a].fileext)) {
  363. path = item[a].filepath;
  364. down = '<span data-href="' + item[a].filepath + '" class="layui-btn layui-btn-xs layui-btn-normal file-view-img">预览</span>';
  365. } else if (doc.includes(item[a].fileext)) {
  366. path = '/static/home/images/icon/' + item[a].fileext + '.png';
  367. }
  368. if (item[a].fileext == 'pdf') {
  369. down = '<span data-href="' + item[a].filepath + '" class="layui-btn layui-btn-xs layui-btn-normal file-view-pdf">预览</span>';
  370. }
  371. 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 +
  372. '" style="object-fit: contain;" class="file-item"><p title="' + item[a].name + '">' + item[a].name +
  373. '</p><div class="layui-btn-group">' + down +
  374. '<span class="layui-btn layui-btn-xs layui-btn-danger file-del">删除</span></div></li>';
  375. }
  376. return li;
  377. }
  378. }
  379. $('#filesBox').on('click', '.file-del', function () {
  380. let id = $(this).parent().parent().data('id');
  381. layer.confirm('确定要删除该文件吗?', {icon: 3, title: '提示'}, function () {
  382. let callback = function (e){
  383. layer.closeAll();
  384. if (e.hasOwnProperty("msg")) {
  385. layer.msg(e.msg);
  386. }
  387. if(e.code==0){
  388. var index = file_ids.indexOf(id);
  389. if (index > -1) {
  390. file_ids.splice(index, 1);
  391. }
  392. if (file_ids.length == 0) {
  393. $("#filesBox").append('<div id="nofile" class="layui-data-none" >暂无附件</div>');
  394. }
  395. $("#" + id).remove();
  396. }
  397. }
  398. tool.delete("/admin/project.api/delete_file", {id: id}, callback)
  399. });
  400. })
  401. oaTool.addFile({
  402. type: 1,
  403. isSave: true,
  404. ajaxSave: function (res) {
  405. if(file_ids.length<1){
  406. console.log(file_ids.length)
  407. let callback = function (e) {
  408. if (e.hasOwnProperty("msg")) {
  409. layer.msg(e.msg);
  410. } else {
  411. layer.msg('上传成功!')
  412. }
  413. if (e[0].id) {
  414. file_ids.push(e[0].id)
  415. $('#nofile').remove();
  416. $("#filesBox").append(fileCard(e));
  417. }
  418. }
  419. tool.post("/admin/project.api/add_file", {
  420. 'file_id': res.data.id,
  421. }, callback);
  422. }else {
  423. layer.msg('仅可上传一份文件!')
  424. }
  425. }
  426. });
  427. }
  428. </script>
  429. <script>
  430. // 获取具有指定 ID 的 <ul> 元素
  431. var ulElement = document.getElementById("filesBox");
  432. // 检查 <ul> 元素的子元素数量
  433. if (ulElement.children.length === 0) {
  434. // 如果子元素数量为 0,隐藏 <ul> 元素
  435. ulElement.style.display = "none";
  436. }
  437. </script>
  438. {/block}
  439. <!-- /脚本 -->