read.html 13 KB

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