add.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. {extend name="common/base"/}
  2. {block name="style"}
  3. <style>
  4. .footer {
  5. width: 100%;
  6. height: 25px;
  7. text-align: center;
  8. margin-bottom: 0 !important;
  9. display: none;
  10. }
  11. .heading th {
  12. text-align: center;
  13. }
  14. .form td {
  15. text-align: center;
  16. }
  17. /* 日志 */
  18. .log_top {
  19. padding-left: 1vw;
  20. }
  21. .log_top span {
  22. margin: 0 0.5vw;
  23. }
  24. /* 1,1,1 */
  25. .log_commentary {
  26. color: rgb(0, 176, 80);
  27. }
  28. .log_company {
  29. color: rgb(255, 33, 0);
  30. }
  31. .log_content {
  32. width: fit-content;
  33. margin: 0.3vw 1.5vw 1vw 1.5vw;
  34. padding: 0.5vw 0vw;
  35. text-indent: 1.2em;
  36. line-height: 2.1vh;
  37. background-color: rgb(255, 255, 255);
  38. border-radius: 0.5vw;
  39. box-shadow: 0.19vw 0.16vw 0.4vw 0.03vw rgba(0, 0, 0, 0.13);
  40. }
  41. .log_content_color {
  42. /* background-color: rgb(250,250,250); */
  43. }
  44. .log_content_img img {
  45. /* width: 10%; */
  46. height: 150px;
  47. border-radius: 0.5vw;
  48. margin: 0.3vw 0;
  49. padding-right: 18px;
  50. padding-bottom: 7px;
  51. padding-left: 2px;
  52. }
  53. .log_item_top {
  54. height: 70%;
  55. overflow: scroll;
  56. }
  57. .log_item_top {
  58. height: 60vh;
  59. }
  60. .log_item_bottom {
  61. display: flex;
  62. /* height: 17vh; */
  63. /* border-top: 1px solid #eee; */
  64. margin: 0 1.5vw;
  65. /* background-color: rgb(250,250,250); */
  66. }
  67. .log_input input {
  68. width: 55vw;
  69. height: 10vh;
  70. border: #eee 1px solid;
  71. }
  72. .log_bottom_img {
  73. /* height: 5vh; */
  74. }
  75. .log_bottom_img img {
  76. height: 4vw;
  77. width: 6vw;
  78. border-radius: 0.5vw;
  79. margin: 0.5vw 0vw 0.5vw 0.3vw;
  80. }
  81. .log_bottom_left {
  82. width: 100%;
  83. margin-top: 1.5vh;
  84. }
  85. .log_bottom_right {
  86. width: 5%;
  87. }
  88. /* 上传图片 */
  89. .layui-upload-drag-self {
  90. background-color: #fbfdff;
  91. border: 1px dashed #c0ccda;
  92. border-radius: 6px;
  93. box-sizing: border-box;
  94. line-height: 4vw;
  95. vertical-align: top;
  96. display: inline-block;
  97. text-align: center;
  98. cursor: pointer;
  99. outline: 0;
  100. margin-right: 13px;
  101. float: left;
  102. }
  103. .layui-input-inlines-self {
  104. position: relative;
  105. margin-left: 90px;
  106. min-height: 36px;
  107. text-align: left;
  108. }
  109. .layui-upload-drag-self .layui-icon {
  110. font-size: 28px;
  111. color: #8c939d
  112. }
  113. .layui-upload-drag-self .img {
  114. position: relative;
  115. height: 148px;
  116. width: 148px;
  117. }
  118. .layui-upload-img {
  119. width: 148px;
  120. height: 148px;
  121. border-radius: 6px;
  122. margin-top: -3px;
  123. margin-left: -2px;
  124. }
  125. .handle {
  126. position: absolute;
  127. width: 148px;
  128. height: 100%;
  129. z-index: 100;
  130. border-radius: 6px;
  131. top: 0;
  132. background: rgba(59, 60, 61, 0.6);
  133. text-align: center;
  134. }
  135. .handle .icon-myself {
  136. z-index: 999;
  137. transition: all .3s;
  138. cursor: pointer;
  139. font-size: 25px;
  140. width: 25px;
  141. color: rgba(255, 255, 255, 0.91);
  142. margin: 0 4px;
  143. }
  144. .log_textarea {
  145. width: 89vw;
  146. height: 8vh;
  147. padding: 0.5vw;
  148. /* margin-right: 2vw; */
  149. margin: 1vw;
  150. }
  151. .log_button_img {
  152. width: 2vw;
  153. }
  154. .log_card {
  155. border: none !important;
  156. }
  157. /* 点击图片放大 */
  158. .content_img img {
  159. max-width: 100%;
  160. cursor: pointer;
  161. }
  162. .overlay {
  163. display: none;
  164. position: fixed;
  165. top: 0;
  166. left: 0;
  167. width: 100%;
  168. height: 100%;
  169. background-color: rgba(0, 0, 0, 0.7);
  170. justify-content: center;
  171. z-index: 1;
  172. }
  173. .overlay img {
  174. margin-top: 4%;
  175. max-width: 90%;
  176. max-height: 90%;
  177. object-fit: contain;
  178. }
  179. .p-4 {
  180. background-color: rgb(255, 255, 255);
  181. }
  182. /*表格*/
  183. #tabniubi {
  184. width: 100%;
  185. margin: 10px 0;
  186. background-color: #fff;
  187. color: #5f5f5f;
  188. }
  189. #tabniubi th {
  190. padding: 9px 15px;
  191. min-height: 20px;
  192. height: 40px;
  193. line-height: 40px;
  194. text-align: center;
  195. /* font-size: 14px; */
  196. border-width: 1px;
  197. border-style: solid;
  198. border-color: #e2e2e2;
  199. font: 14px Helvetica Neue, Helvetica, PingFang SC, Tahoma, Arial, sans-serif;
  200. }
  201. #tabniubi tr:first-child {
  202. padding: 0;
  203. min-height: 0;
  204. line-height: 0;
  205. border-width: 0;
  206. border-style: none;
  207. border-color: #fff;
  208. font-size: 0;
  209. }
  210. #tabniubi tr:first-child th {
  211. padding: 0;
  212. min-height: 0;
  213. line-height: 0;
  214. border-width: 0;
  215. border-style: none;
  216. border-color: #fff;
  217. font-size: 0;
  218. }
  219. .form-title {
  220. background-color: rgb(241, 241, 241);
  221. color: rgb(95, 95, 95);
  222. border-color: rgb(241, 241, 241);
  223. font-weight: 600;
  224. }
  225. .forleft {
  226. text-align: left !important;
  227. }
  228. /* .forright{
  229. text-align:right !important;
  230. } */
  231. .layui-form-select dl dd.layui-this {
  232. background-color: #f8f8f8;
  233. color: rgb(23, 145, 233);
  234. font-weight: 700;
  235. }
  236. .layui-input, .layui-textarea {
  237. /* padding-left: 3.75vw; */
  238. color: #5f5f5f;
  239. }
  240. .upimg {
  241. width: 250px;
  242. height: 250px;
  243. }
  244. .fujianimg img {
  245. height: 5.5vh;
  246. }
  247. .filelist {
  248. width: 100%;
  249. overflow: auto;
  250. justify-content: flex-start;
  251. align-content: space-between;
  252. flex-direction: column-reverse;
  253. flex-wrap: wrap;
  254. display: flex;
  255. }
  256. .filelist li {
  257. padding: 0.5vw 0.8vw 0.5vw 0.8vw;
  258. white-space: nowrap;
  259. overflow: hidden;
  260. text-overflow: ellipsis;
  261. display: inline-block;
  262. border-right: 1px solid #e2e2e2;
  263. float: left;
  264. }
  265. .filelist p {
  266. margin: 3px 0 5px 0;
  267. width: 7vw;
  268. overflow: hidden;
  269. text-overflow: ellipsis;
  270. text-align: center;
  271. }
  272. #filesBox2 li {
  273. padding: 0.5vw 0.8vw 0.5vw 0.8vw;
  274. white-space: nowrap;
  275. overflow: hidden;
  276. text-overflow: ellipsis;
  277. display: inline-block;
  278. border-right: 1px solid #e2e2e2;
  279. float: left;
  280. }
  281. </style>
  282. {/block}
  283. <!-- 主体 -->
  284. {block name="body"}
  285. <form class="layui-form p-4">
  286. <h3 class="pb-3">新建造价项目</h3>
  287. <table id="tabniubi" cellpadding="1" cellspacing="1">
  288. <tr>
  289. <th style="width: 10%;height: 0;"></th>
  290. <th style="width: 10%;height: 0;"></th>
  291. <th style="width: 10%;height: 0;"></th>
  292. <th style="width: 10%;height: 0;"></th>
  293. <th style="width: 10%;height: 0;"></th>
  294. <th style="width: 10%;height: 0;"></th>
  295. <th style="width: 10%;height: 0;"></th>
  296. <th style="width: 10%;height: 0;"></th>
  297. <th style="width: 10%;height: 0;"></th>
  298. </tr>
  299. <tr border="1">
  300. <th class="form-title">项目名称 <font style="color: red !important;">*</font></th>
  301. <th colspan="2">
  302. <input type="text" name="project_name" lay-verify="required" lay-reqText="请完善项目名称" value=""
  303. autocomplete="off" placeholder="请输入项目名称" class="layui-input">
  304. </th>
  305. <th class="form-title">项目编号 <font style="color: red !important;">*</font></th>
  306. <th colspan="2">
  307. <input type="text" name="project_num" lay-verify="required" lay-reqText="请完善项目编号" value=""
  308. autocomplete="off" placeholder="请输入项目编号" class="layui-input">
  309. </th>
  310. <th class="form-title">工程类别</th>
  311. <th colspan="2">
  312. <select name="engineering_category" lay-verify="engineering_category" >
  313. <option value="">请选择工程类型</option>
  314. <option value="建筑物" >建筑物</option>
  315. <option value="交通" >交通</option>
  316. <option value="水利" >水利</option>
  317. <option value="土地整治" >土地整治</option>
  318. <option value="市政园林" >市政园林</option>
  319. <option value="信息网络" >信息网络</option>
  320. <option value="其他" >其他</option>
  321. </select>
  322. </th>
  323. <!-- <th class="form-title">项目周期 <font style="color: red !important;">*</font></th>-->
  324. <!-- <th id="date" colspan="2">-->
  325. <!-- <div class="layui-input-inline" style="width: 47%;display: inline-flex;">-->
  326. <!-- <input type="text" id="start_time" name="project_start_time" readonly lay-verify="required"-->
  327. <!-- lay-reqText="请选择开始时间" placeholder="请选择" class="layui-input" value="">-->
  328. <!-- </div>-->
  329. <!-- - -->
  330. <!-- <div class="layui-input-inline" style="width: 47%;display: inline-flex;">-->
  331. <!-- <input type="text" id="end_time" name="project_end_time" readonly lay-verify="required"-->
  332. <!-- lay-reqText="请选择结束时间" placeholder="请选择" class="layui-input" value="">-->
  333. <!-- </div>-->
  334. <!-- </th>-->
  335. </tr>
  336. <tr>
  337. <th class="form-title">项目类型<font style="color: red !important;">*</font></th>
  338. <th colspan="2">
  339. <div>
  340. <select name="engineering_type1" lay-verify="required">
  341. <option value="">请选择项目类型</option>
  342. <option value="1">预算</option>
  343. <option value="2">结算</option>
  344. <option value="3">概算</option>
  345. <option value="4">决算</option>
  346. <option value="5">工程总承包(EPC)</option>
  347. </select>
  348. </div>
  349. </th>
  350. <th class="form-title">——</th>
  351. <th colspan="2">
  352. <div>
  353. <select name="engineering_type2" lay-verify="required">
  354. <option value="">请选择项目类型</option>
  355. <option value="1">审核</option>
  356. <option value="2">编制</option>
  357. </select>
  358. </div>
  359. </th>
  360. </tr>
  361. <tr>
  362. <th class="form-title">项目区域</th>
  363. <th colspan="2">
  364. <div>
  365. <div class="layui-form-item"
  366. style="margin-bottom: 0;display: flex;flex-direction: row;justify-content: space-between;">
  367. <div class="layui-input-inline" style="width: 6.5vw;">
  368. <select id="province" lay-filter="province" name="province"></select>
  369. </div>
  370. <div class="layui-input-inline area" style="width: 6.5vw;">
  371. <select id="city" lay-filter="city" name="city"></select>
  372. </div>
  373. <div class="layui-input-inline area" style="width: 6.5vw;">
  374. <select id="area" lay-filter="area" name="area"></select>
  375. </div>
  376. </div>
  377. </div>
  378. </th>
  379. </tr>
  380. <tr>
  381. <th class="form-title">资金性质</th>
  382. <th>
  383. <input type="radio" name="fiscal_nature" value="财政资金" title="财政资金" lay-filter="tax" checked>
  384. <input type="radio" name="fiscal_nature" value="非财政资金" title="非财政资金" lay-filter="tax">
  385. </th>
  386. <th class="form-title entrust_unit">委托单位 <font style="color: red !important;">*</font></th>
  387. <th colspan="2" class="entrust_unit">
  388. <input type="text" name="entrust_unit_name" autocomplete="off" readonly value="" lay-reqText="当地的财评" placeholder="当地的财评委托单位" class="layui-input get-entrust">
  389. <input type="hidden" name="entrust_unit" value="">
  390. </th>
  391. <!-- <th class="form-title review_unit">评审单位 <font style="color: red !important;">*</font></th>-->
  392. <!-- <th colspan="2" class="review_unit">-->
  393. <!-- <input type="text" name="review_unit_name" autocomplete="off" readonly value="" lay-reqText="请输入评审单位" placeholder="请输入评审单位" class="layui-input customer-picker">-->
  394. <!-- <input type="hidden" name="review_unit" value="">-->
  395. <!-- </th>-->
  396. </tr>
  397. <tr>
  398. <th class="form-title">审批人 <font style="color: red !important;">*</font></th>
  399. <th colspan="2">
  400. <select name="sent_review_approver" lay-verify="required" lay-reqText="请选择第一审批人">
  401. <option value="">请选择第一审批人</option>
  402. {volist name="person" id="v"}
  403. <option value="{$v.id}">{$v.nickname}</option>
  404. {/volist}
  405. </select>
  406. </th>
  407. <th colspan="2">
  408. <select name="sent_review_second_approver" lay-reqText="请选择第一审批人">
  409. <option value="">请选择第二审批人(可选)</option>
  410. {volist name="person" id="v"}
  411. <option value="{$v.id}">{$v.nickname}</option>
  412. {/volist}
  413. </select>
  414. </th>
  415. </tr>
  416. <tr>
  417. <th colspan="9" class="forleft">相关附件
  418. <button class="layui-btn layui-btn-xs layui-btn-danger" style="float: right;" type="button"
  419. id="uploadBtn">上传附件
  420. </button>
  421. </th>
  422. </tr>
  423. <tr>
  424. <th colspan="9" class="fujianimg" style="padding: 9px 0;">
  425. <div id="filesBox2">
  426. <div class="filelist" id="filesBigBox">
  427. <ul id="filesBox" style="overflow: scroll;">
  428. </ul>
  429. </div>
  430. {empty name="$file_array" }
  431. <div class="layui-data-none">暂无附件</div>
  432. {/empty}
  433. </div>
  434. </th>
  435. </tr>
  436. </table>
  437. <div class="py-3">
  438. <input type="hidden" name="id" value="0"/>
  439. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="add">保存</button>
  440. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="save">提交</button>
  441. </div>
  442. </form>
  443. {/block}
  444. <!-- /主体 -->
  445. <!-- 脚本 -->
  446. {block name="script"}
  447. <script>
  448. var moduleInit = ['tool', 'oaTool'];
  449. var province = '';
  450. if (province == '') {
  451. province = '广西';
  452. city = '南宁市';
  453. area = '青秀区';
  454. }
  455. function Add() {
  456. var input1 = 0, input2 = 0;
  457. input1 = parseInt(document.getElementById("sent_review_amount").value);
  458. input2 = parseInt(document.getElementById("authorize_amount").value);
  459. if (input1 && input2) {
  460. var aa = input2 - input1;
  461. var bb = aa / input1 * 100;
  462. bb = bb.toFixed(2);
  463. $('[name="review_add_reduce_amount"]').val(aa);
  464. $('[name="review_add_reduce_rate"]').val(bb);
  465. $('#review_add_reduce_amount').html(aa);
  466. $('#review_add_reduce_rate').html(bb)
  467. } else {
  468. $('[name="review_add_reduce_amount"]').val('');
  469. $('[name="review_add_reduce_rate"]').val('');
  470. $('#review_add_reduce_amount').html('');
  471. $('#review_add_reduce_rate').html('')
  472. }
  473. // 总审定金额-总送审金额
  474. }
  475. function gouguInit() {
  476. var form = layui.form, tool = layui.tool, oaTool = layui.oaTool;
  477. let adress;
  478. //日期选择
  479. layui.laydate.render({
  480. elem: '#date',
  481. range: ['#start_time', '#end_time'],
  482. rangeLinked: true
  483. });
  484. $(".review_unit").hide();
  485. //radio选择
  486. form.on('radio(tax)', function (data) {
  487. if (data.value == "财政资金") {
  488. console.log(1)
  489. $(".entrust_unit").show();
  490. $(".review_unit").hide();
  491. } else {
  492. $(".review_unit").show();
  493. $(".entrust_unit").hide();
  494. }
  495. });
  496. $('.customer-picker').on('click', function () {
  497. let that = $(this);
  498. let callback = function(data){
  499. console.log(data);
  500. $('[name="review_unit"]').val(data.id);
  501. $('[name="review_unit_name"]').val(data.title);
  502. }
  503. oaTool.customerPicker(callback);
  504. });
  505. $('.get-entrust').on('click', function () {
  506. let that = $(this);
  507. let callback = function(data){
  508. console.log(data);
  509. $('[name="entrust_unit"]').val(data.id);
  510. $('[name="entrust_unit_name"]').val(data.title);
  511. }
  512. oaTool.getEntrust(callback);
  513. });
  514. let c = 1;
  515. //监听提交
  516. form.on('submit(add)', function (data) {
  517. if(data.field.fiscal_nature=="财政资金"){
  518. if(data.field.entrust_unit==""&&data.field.entrust_unit_name==""){
  519. layer.msg("请选择委托单位")
  520. return false;
  521. }
  522. }else {
  523. if(data.field.review_unit==""&&data.field.review_unit_name==""){
  524. layer.msg("请选择评审单位")
  525. return false;
  526. }
  527. }
  528. if (c) {
  529. let callback = function (e) {
  530. c = 1
  531. layer.msg(e.msg);
  532. if (e.code == 0) {
  533. tool.sideClose(1000);
  534. }
  535. }
  536. var engineering_type1 = '';
  537. if (data.field.engineering_type1 == 1) {
  538. engineering_type1 = '预算';
  539. } else if (data.field.engineering_type1 == 2) {
  540. engineering_type1 = '结算';
  541. }
  542. var engineering_type2 = '';
  543. if (data.field.engineering_type2 == 1) {
  544. engineering_type2 = '审核';
  545. } else if (data.field.engineering_type2 == 2) {
  546. engineering_type2 = '编制';
  547. }
  548. if(engineering_type1!==""&&engineering_type2!==""){
  549. data.field.engineering_type = engineering_type1 + "-" + engineering_type2;
  550. }
  551. data.field.file_ids = file_ids;
  552. tool.post("/admin/project.cost_proprietor/add", data.field, callback);
  553. }
  554. c = 0
  555. return false;
  556. });
  557. form.on('submit(save)', function (data) {
  558. if(c){
  559. let callback = function (e) {
  560. layer.msg(e.msg);
  561. if (e.code == 0) {
  562. tool.sideClose(1000);
  563. c = 1
  564. }
  565. }
  566. var engineering_type1 ='';
  567. if(data.field.engineering_type1==1){
  568. engineering_type1 ='预算';
  569. }else if(data.field.engineering_type1==2){
  570. engineering_type1 ='结算';
  571. }
  572. var engineering_type2 = '';
  573. if(data.field.engineering_type2==1){
  574. engineering_type2 ='审核';
  575. }else if(data.field.engineering_type2==2) {
  576. engineering_type2 = '编制';
  577. }
  578. if(engineering_type1!==""&&engineering_type2!==""){
  579. data.field.engineering_type = engineering_type1 + "-" + engineering_type2;
  580. }
  581. data.field.file_ids = file_ids;
  582. console.log("!!!");
  583. tool.post("/admin/project.cost_proprietor/save", data.field, callback);
  584. }
  585. c = 0
  586. return false;
  587. });
  588. function fileCard(item){
  589. var host = window.location.host;
  590. var li = '';
  591. if(item.length>0){
  592. for(var a=0;a<item.length;a++){
  593. let image = ['jpg','jpeg','png','gif'];
  594. let doc = ['doc','docx','xls','xlsx','ppt','pptx','txt','pdf','zip','rar','7z'];
  595. // let down = '<a href="'+item[a].filepath+'" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="'+item[a].name+'">下载</a>';
  596. let down ='<a href="' + item[a]['filepath'] + '" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="' + item[a]['name'] + '">预览</a>';
  597. // 判断元素是否在数组中
  598. let path='/static/home/images/icon/file.png';
  599. if (image.includes(item[a].fileext)) {
  600. path=item[a].filepath;
  601. down = '<span data-href="'+item[a].filepath+'" class="layui-btn layui-btn-xs layui-btn-normal file-view-img">预览</span>';
  602. } else if (doc.includes(item[a].fileext)){
  603. path='/static/home/images/icon/'+item[a].fileext+'.png';
  604. }
  605. if(item[a].fileext == 'pdf'){
  606. down = '<span data-href="'+item[a].filepath+'" class="layui-btn layui-btn-xs layui-btn-normal file-view-pdf">预览</span>';
  607. }
  608. 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+
  609. '" style="object-fit: contain;" class="file-item"><p title="'+item[a].name+'">'+item[a].name+
  610. '</p><div class="layui-btn-group">'+ down +
  611. '<span class="layui-btn layui-btn-xs layui-btn-danger file-del">删除</span></div></li>';
  612. }
  613. return li;
  614. }
  615. }
  616. var file_ids = [];
  617. $('#filesBox').on('click','.file-del',function(){
  618. let id = $(this).parent().parent().data('id');
  619. layer.confirm('确定要删除该文件吗?', { icon: 3, title: '提示' }, function () {
  620. layer.closeAll();
  621. var index = file_ids.indexOf(id);
  622. if (index > -1) {
  623. file_ids.splice(index, 1);
  624. }
  625. if(file_ids.length == 0){
  626. $("#filesBox").append('<div id="nofile" class="layui-data-none" >暂无附件</div>');
  627. }
  628. console.log(file_ids);
  629. $("#" + id).remove();
  630. });
  631. })
  632. oaTool.addFile({
  633. type: 1,
  634. isSave: true,
  635. ajaxSave: function (res) {
  636. let callback = function (e) {
  637. if (e.hasOwnProperty("msg")) {
  638. layer.msg(e.msg);
  639. }else{
  640. layer.msg('上传成功!')
  641. }
  642. $('#nofile').remove();
  643. $("#filesBox").append(fileCard(e));
  644. file_ids.push(e[0].id)
  645. }
  646. tool.post("/admin/project.api/add_file", {
  647. 'file_id': res.data.id,
  648. }, callback);
  649. }
  650. });
  651. $('#filesBox2').on('click', '.file-del', function () {
  652. let id = $(this).parent().parent().data('id');
  653. layer.confirm('确定要删除该文件吗?请慎重', {icon: 3, title: '提示'}, function () {
  654. var index = file_ids.indexOf(id);
  655. if (index > -1) {
  656. file_ids.splice(index, 1);
  657. }
  658. if(file_ids.length == 0){
  659. $("#filesBox").append('<div id="nofile" class="layui-data-none" >暂无附件</div>');
  660. }
  661. console.log(file_ids);
  662. $("#" + id).remove();
  663. });
  664. })
  665. layui.use(['form', 'jquery'], function () {
  666. var form = layui.form;
  667. const $ = layui.jquery;
  668. let adress;
  669. $.ajax({
  670. type: "get", //使用get方式
  671. url: "/static/assets/layui/adress.json", //json文件相对于这个HTML的路径
  672. dataType: "json",
  673. async: false,
  674. success: function (data) {
  675. //这个data就是json数据
  676. adress = data
  677. var province = Object.keys(adress)
  678. var proStrs = '<option value="">省</option>';
  679. for (var i = 0; i < province.length; i++) {
  680. proStrs += '<option value="' + province[i] + '">' + province[i] + '</option>';
  681. }
  682. $("#province").html(proStrs);
  683. layui.form.render("select")
  684. },
  685. error: function () {
  686. layer.alert("地址请求失败!! ");
  687. }
  688. });
  689. function getFirstAttr(obj) {
  690. for (var k in obj) return k;
  691. }
  692. function selectOption(selectedProvince, selectedCity = '', selectedArea = '') {
  693. var proStr = '<option value="">省</option>', cityStr = '<option value="">市</option>',
  694. areaStr = '<option value="">县</option>';
  695. var pro = adress[selectedProvince], ci = adress[selectedProvince][selectedCity];
  696. for (var province in adress) {
  697. if (province == selectedProvince) proStr += '<option value="' + province + '" selected>' + province + '</option>';
  698. else proStr += '<option value="' + province + '">' + province + '</option>';
  699. }
  700. $("#province").html(proStr);
  701. for (var city in pro) {
  702. if (city == selectedCity) cityStr += '<option value="' + city + '" selected>' + city + '</option>';
  703. else cityStr += '<option value="' + city + '">' + city + '</option>';
  704. }
  705. $("#city").html(cityStr);
  706. for (var area in ci) {
  707. if (area == "remove") {
  708. continue;
  709. }
  710. if (ci[area] == selectedArea) areaStr += '<option value="' + ci[area] + '" selected>' + ci[area] + '</option>';
  711. else areaStr += '<option value="' + ci[area] + '">' + ci[area] + '</option>';
  712. }
  713. $("#area").html(areaStr);
  714. form.render();
  715. }
  716. /*selectOption(1,2, 3);*/
  717. form.on('select(province)', function (data) {
  718. let thisProvince = data.value;
  719. let thisCity = getFirstAttr(adress[thisProvince]);
  720. selectOption(data.value);
  721. });
  722. form.on('select(city)', function (data) {
  723. selectOption($("#province").val(), data.value, getFirstAttr(data.value));
  724. });
  725. })
  726. }
  727. </script>
  728. {/block}
  729. <!-- /脚本 -->