tb-business-edit.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>入境登记-添加/修改</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  8. <!-- 所有的 css js 资源 -->
  9. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="../../static/kj/vue.min.js"></script>
  12. <script src="../../static/kj/element-ui/index.js"></script>
  13. <script src="../../static/kj/httpVueLoader.js"></script>
  14. <script src="../../static/kj/jquery.min.js"></script>
  15. <script src="../../static/kj/layer/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. <script src="../../static/kj/upload-util.js"></script>
  18. <style type="text/css">
  19. .c-panel .el-form .c-label {
  20. width: 7em !important;
  21. }
  22. .c-panel .el-form .c-panel .el-form {
  23. width: 180px;
  24. }
  25. .item-num .el-input__inner {
  26. width: 100px;
  27. }
  28. .xj {
  29. display: inline;
  30. color: red;
  31. margin-left: 9px;
  32. font-weight: bold;
  33. }
  34. .hj {
  35. color: red;
  36. margin-left: 9px;
  37. font-weight: bold;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  43. <!-- ------- 内容部分 ------- -->
  44. <div class="s-body">
  45. <div class="c-panel">
  46. <div class="c-title" v-if="id == 0">数据添加</div>
  47. <div class="c-title" v-else>数据修改</div>
  48. <el-form v-if="m" label-position="left">
  49. <el-row>
  50. <el-col span=10>
  51. <el-card class="box-card">
  52. <div slot="header" class="clearfix">
  53. <span>基本资料</span>
  54. </div>
  55. <div>
  56. <div class="c-item" v-show="currentCustomerId==1">
  57. <label class="c-label">选择客户:</label>
  58. <el-select v-model="m.customerId" placeholder="请选择" filterable>
  59. <el-option v-for="item in customerList" :key="item.id"
  60. :label="item.name" :value="item.id">
  61. </el-option>
  62. </el-select>
  63. </div>
  64. <div class="c-item">
  65. <label class="c-label">运输货品:</label>
  66. <el-select v-model="m.goodsName" placeholder="请选择" @change="goodsChange">
  67. <el-option v-for="item in goodsList" :key="item.id" :label="item.name"
  68. :value="item.name">
  69. </el-option>
  70. </el-select>
  71. </div>
  72. <sa-item type="num" name="载重(吨)" placeholder="请输入车辆载重" v-model="m.netWeight" br>
  73. </sa-item>
  74. <sa-item type="text" name="境外车牌号" placeholder="请输入境外车牌号" v-model="m.cardNo" br>
  75. </sa-item>
  76. </sa-item>
  77. <div class="c-item">
  78. <label class="c-label">境外车规格:</label>
  79. <el-autocomplete v-model="m.cardSize" placeholder="请输入车规格"
  80. @select="handleSelectCarSize" value-key='unit'
  81. :fetch-suggestions="queryCaSizerAsync">
  82. </el-autocomplete>
  83. </div>
  84. <sa-item type="text" name="中国车牌" placeholder="请输入中国车牌" v-model="m.chinaCarNo"
  85. br></sa-item>
  86. <sa-item type="text" name="中国司机" placeholder="请输入中国车司机" v-model="m.driverName"
  87. br></sa-item>
  88. <sa-item type="text" name="联系号码" placeholder="请输入联系号码" v-model="m.driverPhone"
  89. br></sa-item>
  90. <sa-item type="datetime" name="预计入场" placeholder="请选择" v-model="m.expectInDay"
  91. br></sa-item>
  92. </div>
  93. </el-card>
  94. </el-col>
  95. <el-col span=14>
  96. <el-card class="box-card">
  97. <div slot="header" class="clearfix">
  98. <span>业务项</span>
  99. </div>
  100. <div>
  101. <el-form-item v-for="(type,index) in filterTypeList" style="display: flex;"
  102. v-if="filterTypeList.length>0">
  103. <label slot="label"><label v-if="needTypeId.indexOf(type.id)!==-1"
  104. style="color: red;">*</label>{{type.name}}</label>
  105. <el-select v-model="type.itemId" style="width: 120px;" placeholder="请选择">
  106. <el-option v-for="item in type.items"
  107. v-if="m.netWeight >= item.minWeight && m.netWeight < item.maxWeight
  108. &&m.cardSize<=item.carLength&&m.cardSize>=item.minLength"
  109. :key="item.id" :label="item.itemName" :value="item.id">
  110. </el-option>
  111. </el-select>
  112. <el-input-number style="margin-left: 60px;" class="item-num"
  113. v-model="type.num" :min="1" :max="10" size="mini"
  114. :disabled="type.inc==0"></el-input-number>
  115. <div class="xj" v-if="type.itemId">
  116. {{type.items.filter(obj=>obj.id==type.itemId)[0].price*type.num}}元
  117. <label @click="type.itemId=''"
  118. style="margin-left: 5px;cursor: pointer">(<i
  119. class="el-icon-delete"></i>)</label>
  120. </div>
  121. <el-button v-if="type.code=='p09'&&type.itemId"
  122. @click="addPeopleFn(type.itemId,type.num,true)">操作</el-button>
  123. </el-form-item>
  124. <div v-if="filterTypeList.length==0" style="height: 400px;padding: 30px;">
  125. 请先选择运输货品
  126. </div>
  127. <div class="hj" v-if="totalPrice>0">
  128. 合计费用:{{totalPrice}}<label>元</label>
  129. </div>
  130. </div>
  131. </el-card>
  132. </el-col>
  133. </el-row>
  134. </el-form>
  135. </div>
  136. </div>
  137. <!-- ------- 底部按钮 ------- -->
  138. <div class="s-foot">
  139. <el-button type="primary" @click="ok()">确定</el-button>
  140. <el-button @click="closeFn()">取消</el-button>
  141. </div>
  142. <el-dialog title="人员核酸检测" :visible.sync="modal.visible" width="80%">
  143. <el-card class="box-card">
  144. <div slot="header">
  145. <span>列表</span>
  146. <el-button style="float: right;" icon="el-icon-plus" type="primary" @click="showAddModal"
  147. v-if="modal.list.length<modal.num">添加
  148. </el-button>
  149. </div>
  150. <el-table :data="modal.list">
  151. <el-table-column prop="name" label="姓名">
  152. </el-table-column>
  153. <el-table-column prop="phone" label="联系号码">
  154. </el-table-column>
  155. <!-- <sa-td type="img-list" name="核酸报告" prop="ticket"></sa-td> -->
  156. <el-table-column label="操作">
  157. <template slot-scope="s">
  158. <!-- <el-button class="c-btn" type="primary" @click="uploadFn(s.row)">上传</el-button> -->
  159. <el-button class="c-btn" type="info" @click="editFn(s.row)">修改</el-button>
  160. <el-button class="c-btn" type="danger" @click="deleteFn(s.row)">删除</el-button>
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. </el-card>
  165. <span slot="footer" class="dialog-footer">
  166. <el-button @click="cancelAdd">取 消</el-button>
  167. <el-button type="primary" @click="modal.visible=false">确 定</el-button>
  168. </span>
  169. </el-dialog>
  170. <el-dialog title="人员核酸检测" :visible.sync="addModal.visible" width="400">
  171. <span>
  172. <el-form label-position="left">
  173. <sa-item type="text" name="姓名" placeholder="姓名" v-model="addModal.form.name" br></sa-item>
  174. <sa-item type="text" name="联系号码" placeholder="联系号码" v-model="addModal.form.phone" br></sa-item>
  175. </el-form>
  176. </span>
  177. <span slot="footer" class="dialog-footer">
  178. <el-button @click="addModal.visible = false">取 消</el-button>
  179. <el-button type="primary" @click="confirmAdd">确 定</el-button>
  180. </span>
  181. </el-dialog>
  182. </div>
  183. <script>
  184. var app = new Vue({
  185. components: {
  186. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  187. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue')
  188. },
  189. el: '.vue-box',
  190. data: {
  191. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  192. m: {
  193. id: '', // 主键
  194. customerId: '', // 客户id
  195. customerName: '', // 客户名称
  196. no: '', // 编号
  197. cardNo: '', // 车牌号
  198. countryName: '越南车',
  199. cardSize: '', // 车规格
  200. netWeight: '', // 载重(kg)
  201. goodsName: '', // 商品
  202. chinaCarNo: '',
  203. expectInDay: '',
  204. driverName: '', // 司机名称
  205. driverPhone: '', // 司机联系号码
  206. driverIdCard: '', // 司机身份证
  207. payTicket: '', // 支付凭证
  208. }, // 实体对象
  209. customerList: [],
  210. cardList: [],
  211. driverList: [],
  212. currentCustomerId: 1,
  213. itemTypeList: [],
  214. filterTypeList: [],
  215. goodsList: [],
  216. countryList: [{
  217. name: '越南车'
  218. }, {
  219. name: '中国车'
  220. }],
  221. tableData: [],
  222. modal: {
  223. visible: false,
  224. itemId: 4,
  225. num: 1,
  226. list: []
  227. },
  228. addModal: {
  229. visible: false,
  230. form: {
  231. name: '',
  232. phone: '',
  233. itemId: 4,
  234. ticket: ''
  235. }
  236. },
  237. unitList: [],
  238. needTypeId: []
  239. },
  240. computed: {
  241. totalPrice() {
  242. let itemList = this.itemTypeList.filter(obj => obj.itemId);
  243. let price = 0;
  244. for (let i in itemList) {
  245. let type = itemList[i];
  246. let num = type.num;
  247. let items = type.items;
  248. for (let j in items) {
  249. let item = items[j];
  250. if (item.id == type.itemId) {
  251. price += num * item.price;
  252. break;
  253. }
  254. }
  255. }
  256. return price;
  257. }
  258. },
  259. methods: {
  260. goodsChange(value) {
  261. let goods = this.goodsList.filter(obj => obj.name === value).pop();
  262. let noNeedIds = goods.noNeedIds.split(',');
  263. this.needTypeId = goods.needIds.split(',');
  264. this.filterTypeList = this.itemTypeList.filter(type => noNeedIds.indexOf(type.id) === -1);
  265. },
  266. getUnitList() {
  267. sa.ajax('/TbUnit/getList', {
  268. pageNo: 1,
  269. pageSize: 50
  270. }, function(resp) {
  271. this.unitList = resp.data;
  272. }.bind(this))
  273. },
  274. addPeopleFn(itemId, num, show) {
  275. sa.ajax('/TbBusinessPeople/getList', {
  276. businessId: this.id
  277. }, function(resp) {
  278. let list = resp.data;
  279. let index = 0;
  280. let r = [];
  281. for (let i in list) {
  282. r.push({
  283. name: list[i].name,
  284. phone: list[i].phone,
  285. index: index,
  286. id: list[i].id
  287. })
  288. index++;
  289. }
  290. this.modal.list = r;
  291. }.bind(this));
  292. this.modal.itemId = itemId;
  293. this.modal.num = num;
  294. this.modal.visible = show;
  295. },
  296. showAddModal() {
  297. Object.assign(this.addModal, {
  298. visible: true,
  299. form: {
  300. index: -1,
  301. name: '',
  302. phone: '',
  303. itemId: this.modal.itemId,
  304. ticket: ''
  305. }
  306. })
  307. },
  308. cancelAdd() {
  309. this.modal.list = [];
  310. this.modal.visible = false;
  311. },
  312. confirmAdd() {
  313. if (!this.addModal.form.name) {
  314. sa.error('请输入检测人姓名')
  315. return false;
  316. }
  317. let phone = this.addModal.form.phone;
  318. if (phone && !sa.isPhone(phone)) {
  319. sa.error('检测人联系号码不正确')
  320. return false;
  321. }
  322. let dbIndex = this.addModal.form.index;
  323. if (dbIndex >= 0) {
  324. this.modal.list[dbIndex].name = this.addModal.form.name;
  325. this.modal.list[dbIndex].phone = this.addModal.form.phone;
  326. } else {
  327. this.addModal.form.index = this.modal.list.length;
  328. this.modal.list.push(this.addModal.form);
  329. }
  330. this.addModal.visible = false;
  331. },
  332. editFn(data) {
  333. Object.assign(this.addModal, {
  334. visible: true,
  335. form: data
  336. })
  337. },
  338. deleteFn(data) {
  339. this.modal.list.splice(data.index, 1);
  340. if (data.id) {
  341. sa.ajax('/TbBusinessPeople/deleteById', {
  342. id: data.id
  343. }, function(resp) {
  344. }.bind(this))
  345. }
  346. },
  347. getGoods() {
  348. sa.ajax('/TbGoods/getList', {
  349. pageNo: 1,
  350. pageSize: 10
  351. }, function(resp) {
  352. this.goodsList = resp.data;
  353. }.bind(this))
  354. },
  355. getItemTypeList() {
  356. sa.ajax('/TbItemType/getList', function(resp) {
  357. let typeList = resp.data;
  358. // 初始化数据
  359. sa.ajax('/TbBusiness/getById?id=' + this.id, function(res) {
  360. let m = res.data;
  361. let items = m.items;
  362. let hsItem = items.filter(obj => obj.itemTypeName.indexOf('人') !== -1 &&
  363. obj.itemTypeName.indexOf('核酸') !== -1);
  364. if (hsItem.length > 0) {
  365. this.addPeopleFn(hsItem[0].itemTypeId, false)
  366. }
  367. for (let i in items) {
  368. let item = items[i];
  369. for (let j in typeList) {
  370. let type = typeList[j];
  371. if (item.itemTypeId == type.id) {
  372. type.itemId = item.itemId;
  373. type.num = item.num;
  374. }
  375. }
  376. }
  377. this.m = m;
  378. this.itemTypeList = typeList;
  379. this.goodsChange(m.goodsName);
  380. }.bind(this))
  381. }.bind(this))
  382. },
  383. queryCaSizerAsync(queryStr, cb) {
  384. let list = this.unitList;
  385. let filterList = list.filter(obj => obj.unit.indexOf(queryStr) !== -1);
  386. cb(filterList)
  387. },
  388. handleSelectCarSize(item) {
  389. this.m.cardSize = item.unit;
  390. },
  391. getCustomerList() {
  392. sa.ajax('/TbCostomer/getList', {
  393. pageNo: 1,
  394. pageSize: 100,
  395. judgeStatus: 2
  396. }, function(resp) {
  397. this.customerList = resp.data;
  398. if (resp.data.length > 0) {
  399. this.m.customerId = resp.data[0].id;
  400. }
  401. }.bind(this));
  402. },
  403. getCustomer() {
  404. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  405. let id = resp.data;
  406. if (id == 1) {
  407. this.getCustomerList();
  408. } else {
  409. this.m.customerId = id;
  410. }
  411. this.currentCustomerId = id;
  412. }.bind(this));
  413. },
  414. closeFn() {
  415. parent.app.f5();
  416. sa.closeCurrIframe();
  417. },
  418. // 提交数据
  419. ok: function() {
  420. // 表单校验
  421. let m = this.m;
  422. if (this.currentCustomerId == 1) {
  423. sa.checkNull(m.customerId, '请选择 [客户名称]');
  424. }
  425. sa.checkNull(m.goodsName, '请选择运输货物');
  426. sa.checkNull(m.cardNo, '请输入 [车牌号]');
  427. if (!sa.isNum(m.cardSize)) {
  428. sa.error('车辆规格只能输入数字')
  429. return;
  430. }
  431. if (!sa.isNum(m.netWeight)) {
  432. sa.error('载重只能输入数字')
  433. return;
  434. }
  435. sa.checkNull(m.driverName, '请输入 [中国司机名称]');
  436. if (!sa.isPhone(m.driverPhone)) {
  437. sa.error('司机联系号码不正确')
  438. return false;
  439. }
  440. sa.checkNull(m.chinaCarNo, '请输入 [中国车牌号]');
  441. let checkList = this.itemTypeList;
  442. for (let j in this.needTypeId) {
  443. let id = this.needTypeId[j];
  444. for (let i in checkList) {
  445. let type = checkList[i];
  446. if (id == type.id && !type.itemId) {
  447. sa.error('选择[' + this.m.goodsName + ']时,[' + type.name + ']必选')
  448. return;
  449. }
  450. }
  451. }
  452. let typeList = this.itemTypeList.filter(obj => obj.itemId);
  453. let list = [];
  454. if (typeList.length == 0) {
  455. sa.error('至少选择一项业务');
  456. return false;
  457. }
  458. for (let i in typeList) {
  459. let type = typeList[i];
  460. list.push({
  461. itemId: type.itemId,
  462. num: type.num
  463. })
  464. }
  465. if (typeList.filter(obj => obj.name.indexOf('人') !== -1 && obj.name.indexOf('核酸') !== -1)
  466. .length > 0 &&
  467. this.modal.list
  468. .length == 0) {
  469. sa.error('请添加核酸检测人员');
  470. return false;
  471. }
  472. m.itemJson = JSON.stringify(list);
  473. m.peopleJson = JSON.stringify(this.modal.list);
  474. m.items = [];
  475. if (this.id <= 0) { // 添加
  476. sa.ajax('/TbBusiness/add', m, function(res) {
  477. sa.alert('增加成功', this.clean);
  478. }.bind(this));
  479. } else { // 修改
  480. sa.ajax('/TbBusiness/update', m, function(res) {
  481. sa.alert('修改成功', this.clean);
  482. }.bind(this));
  483. }
  484. },
  485. // 添加/修改 完成后的动作
  486. clean: function() {
  487. this.modal.list = [];
  488. if (this.id == 0) {
  489. this.m = this.createModel();
  490. } else {
  491. parent.app.f5(); // 刷新父页面列表
  492. sa.closeCurrIframe(); // 关闭本页
  493. }
  494. }
  495. },
  496. mounted: function() {
  497. this.getCustomer();
  498. this.getItemTypeList();
  499. this.getGoods();
  500. this.getUnitList();
  501. }
  502. })
  503. </script>
  504. </body>
  505. </html>