tb-business-edit.html 16 KB

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