add.html 17 KB

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