c_read.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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 img {
  11. height: 9vh !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. }
  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. }
  37. .filelist p{
  38. margin: 3px 0 5px 0;
  39. width: 11vw;
  40. overflow: hidden;
  41. text-overflow: ellipsis;
  42. text-align: center;
  43. }
  44. #filesBox2 li{
  45. padding: 0.5vw 0.8vw 0.5vw 0.8vw;
  46. white-space: nowrap;
  47. overflow: hidden;
  48. text-overflow: ellipsis;
  49. display: inline-block;
  50. border-right: 1px solid #e2e2e2;
  51. float: left;
  52. }
  53. .footer{
  54. display: none;
  55. }
  56. .layui-table th{
  57. text-align: center !important;
  58. font-weight: 500;
  59. }
  60. .layui-anim dd{
  61. text-align: left;
  62. }
  63. .layui-th-gray{
  64. background-color: rgb(241, 241, 241);
  65. }
  66. .layui-table th{
  67. border-color: #e2e2e2
  68. }
  69. .forleft {
  70. text-align: left !important;
  71. }
  72. .height{
  73. height: 36px;
  74. }
  75. .layui-btn-group span:last-child{
  76. display: none;
  77. }
  78. </style>
  79. {/block}
  80. <!-- 主体 -->
  81. {block name="body"}
  82. <div class="p-3">
  83. <table class="layui-hide" id="appropriation_add" lay-filter="appropriation_add"></table>
  84. <form class="layui-form p-4">
  85. <table class="layui-table layui-table-form">
  86. <tr>
  87. <th class="layui-th-gray">委托单位</th>
  88. <th colspan="5" style="text-align:left !important;padding-left:2.5vw;">
  89. {$detail.entrust_unit_name}
  90. </th>
  91. <th class="layui-th-gray">是否开票</th>
  92. <th colspan="2">
  93. <input type="radio" name="invoice_status" value="1" title="是" {if $detail.invoicing_whether!=0}checked{/if}>
  94. <input type="radio" name="invoice_status" value="0" title="否" {if $detail.invoicing_whether==0}checked{/if}>
  95. </th>
  96. </tr>
  97. <tr>
  98. <th class="layui-th-gray">发票编号</th>
  99. <th colspan="2">
  100. <input type="text" name="invoicing_num" autocomplete="off" placeholder="请输入发票编号" class="layui-input" value="{$detail.invoicing_num}">
  101. </th>
  102. <th class="layui-th-gray">发票类型</th>
  103. <th colspan="2">
  104. <select name="invoice_type" lay-verify="required">
  105. <option value="0"></option>
  106. <option value="1" {if $detail.invoice_type==1}selected{/if}>普通发票</option>
  107. <option value="2" {if $detail.invoice_type==2}selected{/if}>专用发票</option>
  108. <option value="3" {if $detail.invoice_type==3}selected{/if}>电子普票</option>
  109. <option value="4" {if $detail.invoice_type==4}selected{/if}>电子专票</option>
  110. </select>
  111. </th>
  112. <th class="layui-th-gray">发票金额</th>
  113. <th colspan="2">
  114. <input type="text" name="invoicing_amount" autocomplete="off" placeholder="请输入发票金额" class="layui-input" value="{$detail.invoicing_amount}">
  115. </th>
  116. </tr>
  117. <tr>
  118. <th colspan="9" class="forleft" style="text-align: left !important;">相关附件</th>
  119. </tr>
  120. <tr>
  121. <th colspan="9" class="fujianimg" style="padding: 9px 0;">
  122. <div id="filesBox2">
  123. <div class="filelist" id="filesBigBox">
  124. <ul id="filesBox" style="height: 16.2vh;">
  125. {:fileCard($file_array)}
  126. </ul>
  127. </div>
  128. {empty name="$file_array" }
  129. <div class="layui-data-none" >暂无附件</div>
  130. {/empty}
  131. </div>
  132. </th>
  133. </tr>
  134. </table>
  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_read?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_amount',
  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.pageTable.reload();
  210. layer.msg(e.msg)
  211. }
  212. tool.post("edit", data, callback)
  213. });
  214. let a = 1;
  215. form.on('submit(webform)', function (data) {
  216. let refund_amount = 0;
  217. layui.each(layui.table.cache['appropriation_add'], function (index, row) {
  218. refund_amount += Number(row.refund_amount)
  219. });
  220. data.field.refund_amount = refund_amount;
  221. delete data.field.file;
  222. console.log(data);
  223. if(a){
  224. let callback = function (e) {
  225. layer.msg(e.msg)
  226. parent.location.reload();
  227. if (e.code == 0) {
  228. tool.sideClose(1000);
  229. a = 1
  230. }
  231. }
  232. tool.post("/admin/project.appropriation/cc_edit", data.field, callback)
  233. }
  234. a = 0
  235. return false;
  236. });
  237. form.on('submit(save)', function (data) {
  238. if(a){
  239. let callback = function (e) {
  240. layer.msg(e.msg)
  241. parent.location.reload();
  242. if (e.code == 0) {
  243. tool.sideClose(1000);
  244. a = 1
  245. }
  246. }
  247. tool.post("/admin/project.appropriation/disagree", data.field, callback)
  248. }
  249. a = 0
  250. return false;
  251. });
  252. function fileCard(item) {
  253. var host = window.location.host;
  254. var li = '';
  255. if (item.length > 0) {
  256. for (var a = 0; a < item.length; a++) {
  257. let image = ['jpg', 'jpeg', 'png', 'gif'];
  258. let doc = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'zip', 'rar', '7z'];
  259. // let down = '<a href="'+item[a].filepath+'" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="'+item[a].name+'">下载</a>';
  260. let down = '<a href="' + item[a]['filepath'] + '" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="' + item[a]['name'] + '">预览</a>';
  261. // 判断元素是否在数组中
  262. let path = '/static/home/images/icon/file.png';
  263. if (image.includes(item[a].fileext)) {
  264. path = item[a].filepath;
  265. down = '<span data-href="' + item[a].filepath + '" class="layui-btn layui-btn-xs layui-btn-normal file-view-img">预览</span>';
  266. } else if (doc.includes(item[a].fileext)) {
  267. path = '/static/home/images/icon/' + item[a].fileext + '.png';
  268. }
  269. if (item[a].fileext == 'pdf') {
  270. down = '<span data-href="' + item[a].filepath + '" class="layui-btn layui-btn-xs layui-btn-normal file-view-pdf">预览</span>';
  271. }
  272. 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 +
  273. '" style="object-fit: contain;" class="file-item"><p title="' + item[a].name + '">' + item[a].name +
  274. '</p><div class="layui-btn-group">' + down +
  275. '<span class="layui-btn layui-btn-xs layui-btn-danger file-del">删除</span></div></li>';
  276. }
  277. return li;
  278. }
  279. }
  280. $('#filesBox').on('click', '.file-del', function () {
  281. let id = $(this).parent().parent().data('id');
  282. layer.confirm('确定要删除该文件吗?', {icon: 3, title: '提示'}, function () {
  283. let callback = function (e){
  284. layer.closeAll();
  285. if (e.hasOwnProperty("msg")) {
  286. layer.msg(e.msg);
  287. }
  288. if(e.code==0){
  289. var index = file_ids.indexOf(id);
  290. if (index > -1) {
  291. file_ids.splice(index, 1);
  292. }
  293. if (file_ids.length == 0) {
  294. $("#filesBox").append('<div id="nofile" class="layui-data-none" >暂无附件</div>');
  295. }
  296. $("#" + id).remove();
  297. }
  298. }
  299. tool.delete("/admin/project.api/delete_file", {id: id}, callback)
  300. });
  301. })
  302. oaTool.addFile({
  303. type: 1,
  304. isSave: true,
  305. ajaxSave: function (res) {
  306. if(file_ids.length<1){
  307. console.log(file_ids.length)
  308. let callback = function (e) {
  309. if (e.hasOwnProperty("msg")) {
  310. layer.msg(e.msg);
  311. } else {
  312. layer.msg('上传成功!')
  313. }
  314. if (e[0].id) {
  315. file_ids.push(e[0].id)
  316. $('#nofile').remove();
  317. $("#filesBox").append(fileCard(e));
  318. }
  319. }
  320. tool.post("/admin/project.api/add_file", {
  321. 'file_id': res.data.id,
  322. }, callback);
  323. }else {
  324. layer.msg('仅可上传一份文件!')
  325. }
  326. }
  327. });
  328. }
  329. </script>
  330. <script>
  331. // 获取具有指定 ID 的 <ul> 元素
  332. var ulElement = document.getElementById("filesBox");
  333. // 检查 <ul> 元素的子元素数量
  334. if (ulElement.children.length === 0) {
  335. // 如果子元素数量为 0,隐藏 <ul> 元素
  336. ulElement.style.display = "none";
  337. }
  338. </script>
  339. {/block}
  340. <!-- /脚本 -->