tb-business-add.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. .china-car-size .el-input__inner {
  40. width: 130px;
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  46. <!-- ------- 内容部分 ------- -->
  47. <div class="s-body">
  48. <div class="c-panel">
  49. <div class="c-title" v-if="id == 0">数据添加</div>
  50. <div class="c-title" v-else>数据修改</div>
  51. <el-form v-if="m" label-position="left">
  52. <el-row>
  53. <el-col span=10>
  54. <el-card class="box-card">
  55. <div slot="header" class="clearfix">
  56. <span>基本资料</span>
  57. </div>
  58. <div>
  59. <div class="c-item" v-show="currentCustomerId==1">
  60. <label class="c-label"><span style="color: red;">*</span>选择客户:</label>
  61. <el-select v-model="m.customerId" placeholder="请选择" filterable>
  62. <el-option v-for="item in customerList" :key="item.id"
  63. :label="item.name" :value="item.id">
  64. </el-option>
  65. </el-select>
  66. </div>
  67. <div class="c-item">
  68. <label class="c-label"><span style="color: red;">*</span>运输货品:</label>
  69. <el-select v-model="m.goodsName" placeholder="请选择" @change="goodsChange">
  70. <el-option v-for="item in goodsList" :key="item.id" :label="item.name"
  71. :value="item.name">
  72. </el-option>
  73. </el-select>
  74. </div>
  75. <sa-item type="num" name="载重(吨)" placeholder="请输入车辆载重" v-model="m.netWeight" br>
  76. </sa-item>
  77. <sa-item type="text" name="境外车牌号" placeholder="请输入境外车牌号" v-model="m.cardNo" br>
  78. </sa-item>
  79. </sa-item>
  80. <div class="c-item">
  81. <label class="c-label"><span style="color: red;">*</span>境外车规格:</label>
  82. <el-autocomplete v-model="m.cardSize" placeholder="请输入车规格"
  83. @select="handleSelectCarSize" value-key='unit'
  84. :fetch-suggestions="queryCaSizerAsync">
  85. </el-autocomplete>
  86. </div>
  87. <div class="c-item">
  88. <label class="c-label">中国车:</label>
  89. <el-input v-model="china.list.map(obj=>obj.carNo).join('、')"
  90. placeholder="添加中国车" readonly>
  91. <div slot="suffix" style="cursor: pointer;color: blue;" @click="addCar">
  92. <i class="el-icon-folder-add"></i>
  93. </div>
  94. </el-input>
  95. </div>
  96. </div>
  97. </el-card>
  98. </el-col>
  99. <el-col span=14>
  100. <el-card class="box-card">
  101. <div slot="header" class="clearfix">
  102. <span>业务项</span>
  103. </div>
  104. <div>
  105. <el-form-item v-for="(type,index) in filterTypeList" style="display: flex;"
  106. v-if="filterTypeList.length>0">
  107. <label slot="label">
  108. <label v-if="needTypeId.indexOf(type.id)!==-1"
  109. style="color: red;">*</label>{{type.name}}</label>
  110. <el-select v-model="type.itemId" style="width: 120px;" @change="itemChange"
  111. placeholder="请选择">
  112. <el-option v-for="item in type.items" :key="item.id"
  113. :label="item.itemName" :value="item.id" v-if="m.netWeight >= item.minWeight && m.netWeight < item.maxWeight
  114. &&m.cardSize<=item.carLength&&m.cardSize>=item.minLength">
  115. </el-option>
  116. </el-select>
  117. <el-input-number style="margin-left: 60px;" class="item-num"
  118. v-model="type.num" :min="1" :max="10" size="mini"
  119. :disabled="type.inc==0"></el-input-number>
  120. <div class="xj" v-if="type.itemId">
  121. {{type.items.filter(obj=>obj.id==type.itemId)[0].price*type.num}}元
  122. <label @click="cleanItem(type)"
  123. style="margin-left: 5px;cursor: pointer">(<i
  124. class="el-icon-delete"></i>)</label>
  125. </div>
  126. <el-button v-if="type.code=='p09'&&type.itemId"
  127. @click="addPeopleFn(type.itemId,type.num)">操作</el-button>
  128. </el-form-item>
  129. <div v-if="filterTypeList.length==0" style="height: 400px;padding: 30px;">
  130. 请先选择运输货品
  131. </div>
  132. <div class="hj" v-if="totalPrice>0">
  133. 合计费用:{{totalPrice}}<label>元</label>
  134. </div>
  135. </div>
  136. </el-card>
  137. </el-col>
  138. </el-row>
  139. </el-form>
  140. </div>
  141. </div>
  142. <!-- ------- 底部按钮 ------- -->
  143. <div class="s-foot">
  144. <el-button type="primary" @click="ok()">确定</el-button>
  145. <el-button @click="closeFn()">取消</el-button>
  146. </div>
  147. <el-dialog title="人员核酸检测" :visible.sync="modal.visible" width="80%">
  148. <el-card class="box-card">
  149. <div slot="header">
  150. <span>列表</span>
  151. <el-button style="float: right;" icon="el-icon-plus" type="primary" @click="showAddModal"
  152. v-if="modal.list.length<modal.num">添加
  153. </el-button>
  154. </div>
  155. <el-table :data="modal.list">
  156. <el-table-column prop="name" label="姓名">
  157. </el-table-column>
  158. <el-table-column prop="phone" label="联系号码">
  159. </el-table-column>
  160. <!-- <sa-td type="img-list" name="核酸报告" prop="ticket"></sa-td> -->
  161. <el-table-column label="操作">
  162. <template slot-scope="s">
  163. <!-- <el-button class="c-btn" type="primary" @click="uploadFn(s.row)">上传</el-button> -->
  164. <el-button class="c-btn" type="info" @click="editFn(s.row)">修改</el-button>
  165. <el-button class="c-btn" type="danger" @click="deleteFn(s.row)">删除</el-button>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. </el-card>
  170. <span slot="footer" class="dialog-footer">
  171. <el-button @click="cancelAdd">取 消</el-button>
  172. <el-button type="primary" @click="modal.visible=false">确 定</el-button>
  173. </span>
  174. </el-dialog>
  175. <el-dialog title="人员核酸检测" :visible.sync="addModal.visible" width="400">
  176. <span>
  177. <el-form label-position="left">
  178. <sa-item type="text" name="姓名" placeholder="姓名" v-model="addModal.form.name" br></sa-item>
  179. <sa-item type="text" name="联系号码" placeholder="联系号码" v-model="addModal.form.phone" br></sa-item>
  180. </el-form>
  181. </span>
  182. <span slot="footer" class="dialog-footer">
  183. <el-button @click="addModal.visible = false">取 消</el-button>
  184. <el-button type="primary" @click="confirmAdd">确 定</el-button>
  185. </span>
  186. </el-dialog>
  187. <el-dialog title="添加中国车" :visible.sync="china.visible" width="80%">
  188. <el-card class="box-card">
  189. <div slot="header">
  190. <span>列表</span>
  191. <el-button style="float: right;" icon="el-icon-plus" type="primary" @click="addChinaCarFn">添加
  192. </el-button>
  193. </div>
  194. <el-table :data="china.list">
  195. <el-table-column prop="carNo" label="车牌号">
  196. </el-table-column>
  197. <el-table-column prop="driverName" label="联系人">
  198. </el-table-column>
  199. <el-table-column prop="driverPhone" label="联系号码">
  200. </el-table-column>
  201. <el-table-column prop="carSize" label="车辆规格">
  202. </el-table-column>
  203. <el-table-column label="操作">
  204. <template slot-scope="s">
  205. <el-button class="c-btn" type="info" @click="editChinaCarFn(s.row)">修改</el-button>
  206. <el-button class="c-btn" type="danger" @click="deleteChinaCarFn(s.row)">删除</el-button>
  207. </template>
  208. </el-table-column>
  209. </el-table>
  210. </el-card>
  211. <span slot="footer" class="dialog-footer">
  212. <el-button @click="china.visible=false">关 闭</el-button>
  213. <el-button type="primary" @click="china.visible=false">确 定</el-button>
  214. </span>
  215. </el-dialog>
  216. <el-dialog title="添加中国车" :visible.sync="car.visible" width="300">
  217. <span>
  218. <el-form label-position="left">
  219. <div class="c-item">
  220. <label class="c-label"><span style="color: red;">*</span>车牌号:</label>
  221. <el-input v-model="car.form.carNo" placeholder="车牌号">
  222. </el-input>
  223. </div>
  224. <div class="c-item">
  225. <label class="c-label"><span style="color: red;">*</span>车辆规格:</label>
  226. <el-input-number class="china-car-size" v-model="car.form.carSize" controls-position="right"
  227. :min="4.2" :max="50"></el-input-number>
  228. </div>
  229. <div class="c-item">
  230. <label class="c-label">联系人:</label>
  231. <el-input v-model="car.form.driverName" placeholder="联系人">
  232. </el-input>
  233. </div>
  234. <div class="c-item">
  235. <label class="c-label">联系号码:</label>
  236. <el-input v-model="car.form.driverPhone" placeholder="联系号码">
  237. </el-input>
  238. </div>
  239. </el-form>
  240. </span>
  241. <span slot="footer" class="dialog-footer">
  242. <el-button @click="car.visible = false">取 消</el-button>
  243. <el-button type="primary" @click="confirmAddCar">确 定</el-button>
  244. </span>
  245. </el-dialog>
  246. </div>
  247. <script>
  248. var app = new Vue({
  249. components: {
  250. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  251. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue')
  252. },
  253. el: '.vue-box',
  254. data: {
  255. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  256. m: {
  257. id: '', // 主键
  258. customerId: '', // 客户id
  259. customerName: '', // 客户名称
  260. no: '', // 编号
  261. cardNo: '', // 车牌号
  262. countryName: '越南车',
  263. cardSize: '', // 车规格
  264. netWeight: '', // 载重(kg)
  265. goodsName: '', // 商品
  266. chinaCarNo: '',
  267. expectInDay: '',
  268. driverName: '', // 司机名称
  269. driverPhone: '', // 司机联系号码
  270. driverIdCard: '', // 司机身份证
  271. payTicket: '', // 支付凭证
  272. }, // 实体对象
  273. checkItem:'',
  274. customerList: [],
  275. cardList: [],
  276. driverList: [],
  277. currentCustomerId: 1,
  278. itemTypeList: [],
  279. filterTypeList: [],
  280. goodsList: [],
  281. countryList: [{
  282. name: '越南车'
  283. }, {
  284. name: '中国车'
  285. }],
  286. tableData: [],
  287. modal: {
  288. visible: false,
  289. itemId: 4,
  290. num: 1,
  291. list: []
  292. },
  293. addModal: {
  294. visible: false,
  295. form: {
  296. name: '',
  297. phone: '',
  298. itemId: 4,
  299. ticket: ''
  300. }
  301. },
  302. unitList: [],
  303. needTypeId: [],
  304. china: {
  305. visible: false,
  306. list: []
  307. },
  308. car: {
  309. visible: false,
  310. form: {
  311. carNo: '',
  312. driverName: '',
  313. driverPhone: '',
  314. carSize: ''
  315. }
  316. }
  317. },
  318. computed: {
  319. totalPrice() {
  320. let itemList = this.itemTypeList.filter(obj => obj.itemId);
  321. let price = 0;
  322. for (let i in itemList) {
  323. let type = itemList[i];
  324. let num = type.num;
  325. let items = type.items;
  326. for (let j in items) {
  327. let item = items[j];
  328. if (item.id == type.itemId) {
  329. price += num * item.price;
  330. break;
  331. }
  332. }
  333. }
  334. return price;
  335. }
  336. },
  337. methods: {
  338. cleanItem(type) {
  339. type.itemId = '';
  340. let typeName=type.name;
  341. if (typeName == '干杂货人工装卸' ||typeName == '特殊车辆') {
  342. this.checkItem='';
  343. }
  344. },
  345. itemChange(itemId) {
  346. let items = this.itemTypeList.flatMap(obj => obj.items);
  347. let item = items.filter(obj => obj.id == itemId)[0];
  348. let typeName = item.typeName;
  349. let checkItem = this.checkItem;
  350. if ((typeName == '干杂货人工装卸' && checkItem=='特殊车辆') ||
  351. (typeName == '特殊车辆' && checkItem=='干杂货人工装卸')) {
  352. this.itemTypeList.filter(obj => obj.id == item.typeId)[0].itemId = ''
  353. sa.error('不能同时选择干杂货人工装卸和特殊车辆')
  354. return false;
  355. }
  356. if (typeName == '干杂货人工装卸' ||typeName == '特殊车辆') {
  357. this.checkItem=typeName;
  358. }
  359. },
  360. addCar() {
  361. this.china.visible = true;
  362. },
  363. addChinaCarFn() {
  364. Object.assign(this.car, {
  365. visible: true,
  366. form: {
  367. carNo: '',
  368. driverName: '',
  369. driverPhone: '',
  370. carSize: ''
  371. }
  372. })
  373. },
  374. confirmAddCar() {
  375. let carNo = this.car.form.carNo;
  376. if (!carNo) {
  377. sa.error('请填入车牌号')
  378. return false;
  379. }
  380. if (!this.car.form.carSize) {
  381. sa.error('请填入车辆规格')
  382. return false;
  383. }
  384. let phone = this.car.form.phone;
  385. if (phone && !sa.isPhone(phone)) {
  386. sa.error('联系号码不正确')
  387. return false;
  388. }
  389. let list = this.china.list;
  390. let index = list.map(obj => obj.carNo).indexOf(carNo);
  391. if (index > -1) {
  392. list.splice(index, 1);
  393. }
  394. this.china.list.push(this.car.form);
  395. this.car.visible = false;
  396. },
  397. editChinaCarFn(data) {
  398. Object.assign(this.car, {
  399. visible: true,
  400. form: data
  401. })
  402. },
  403. deleteChinaCarFn(data) {
  404. this.china.list.splice(this.china.list.indexOf(data), 1)
  405. },
  406. goodsChange(value) {
  407. let goods = this.goodsList.filter(obj => obj.name === value).pop();
  408. let noNeedIds = goods.noNeedIds.split(',');
  409. this.needTypeId = goods.needIds.split(',');
  410. this.filterTypeList = this.itemTypeList.filter(type => noNeedIds.indexOf(type.id) === -1);
  411. },
  412. getUnitList() {
  413. sa.ajax('/TbUnit/getList', {
  414. pageNo: 1,
  415. pageSize: 50
  416. }, function(resp) {
  417. this.unitList = resp.data;
  418. }.bind(this))
  419. },
  420. addPeopleFn(itemId, num) {
  421. this.modal.itemId = itemId;
  422. this.modal.num = num;
  423. this.modal.visible = true;
  424. },
  425. showAddModal() {
  426. Object.assign(this.addModal, {
  427. visible: true,
  428. form: {
  429. index: -1,
  430. name: '',
  431. phone: '',
  432. itemId: this.modal.itemId,
  433. ticket: ''
  434. }
  435. })
  436. },
  437. cancelAdd() {
  438. this.modal.list = [];
  439. this.modal.visible = false;
  440. },
  441. confirmAdd() {
  442. if (!this.addModal.form.name) {
  443. sa.error('请输入检测人姓名')
  444. return false;
  445. }
  446. let phone = this.addModal.form.phone;
  447. if (phone && !sa.isPhone(phone)) {
  448. sa.error('检测人联系号码不正确')
  449. return false;
  450. }
  451. let dbIndex = this.addModal.form.index;
  452. if (dbIndex >= 0) {
  453. this.modal.list[dbIndex].name = this.addModal.form.name;
  454. this.modal.list[dbIndex].phone = this.addModal.form.phone;
  455. } else {
  456. this.addModal.form.index = this.modal.list.length;
  457. this.modal.list.push(this.addModal.form);
  458. }
  459. this.addModal.visible = false;
  460. },
  461. editFn(data) {
  462. Object.assign(this.addModal, {
  463. visible: true,
  464. form: data
  465. })
  466. },
  467. deleteFn(data) {
  468. this.modal.list.splice(data.index, 1);
  469. if (data.id) {
  470. sa.ajax('/TbBusinessPeople/deleteById', {
  471. id: data.id
  472. }, function(resp) {
  473. }.bind(this))
  474. }
  475. },
  476. getGoods() {
  477. sa.ajax('/TbGoods/getList', {
  478. pageNo: 1,
  479. pageSize: 10
  480. }, function(resp) {
  481. this.goodsList = resp.data;
  482. }.bind(this))
  483. },
  484. getItemTypeList() {
  485. sa.ajax('/TbItemType/getList', function(resp) {
  486. let typeList = resp.data;
  487. // 初始化数据
  488. if (this.id > 0) {
  489. sa.ajax('/TbBusiness/getById?id=' + this.id, function(res) {
  490. let m = res.data;
  491. let items = m.items;
  492. for (let i in items) {
  493. let item = items[i];
  494. for (let j in typeList) {
  495. let type = typeList[j];
  496. if (item.itemTypeId == type.id) {
  497. type.itemId = item.itemId;
  498. type.num = item.num;
  499. }
  500. }
  501. }
  502. this.m = m;
  503. }.bind(this))
  504. }
  505. this.itemTypeList = typeList;
  506. }.bind(this))
  507. },
  508. queryCaSizerAsync(queryStr, cb) {
  509. let list = this.unitList;
  510. let filterList = list.filter(obj => obj.unit.indexOf(queryStr) !== -1);
  511. cb(filterList)
  512. },
  513. handleSelectCarSize(item) {
  514. this.m.cardSize = item.unit;
  515. },
  516. getCustomerList() {
  517. sa.ajax('/TbCostomer/getList', {
  518. pageNo: 1,
  519. pageSize: 100,
  520. judgeStatus: 2
  521. }, function(resp) {
  522. this.customerList = resp.data;
  523. if (resp.data.length > 0) {
  524. this.m.customerId = resp.data[0].id;
  525. }
  526. }.bind(this));
  527. },
  528. getCustomer() {
  529. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  530. let id = resp.data;
  531. if (id == 1) {
  532. this.getCustomerList();
  533. } else {
  534. this.m.customerId = id;
  535. }
  536. this.currentCustomerId = id;
  537. }.bind(this));
  538. },
  539. closeFn() {
  540. parent.app.f5();
  541. sa.closeCurrIframe();
  542. },
  543. // 提交数据
  544. ok: function() {
  545. // 表单校验
  546. let m = this.m;
  547. if (this.currentCustomerId == 1) {
  548. sa.checkNull(m.customerId, '请选择 [客户名称]');
  549. }
  550. sa.checkNull(m.goodsName, '请选择运输货物');
  551. sa.checkNull(m.cardNo, '请输入 [车牌号]');
  552. if (!sa.isNum(m.cardSize)) {
  553. sa.error('车辆规格只能输入数字')
  554. return;
  555. }
  556. if (!sa.isNum(m.netWeight)) {
  557. sa.error('载重只能输入数字')
  558. return;
  559. }
  560. let checkList = this.itemTypeList;
  561. let chechItem=this.checkItem;
  562. for (let j in this.needTypeId) {
  563. let id = this.needTypeId[j];
  564. for (let i in checkList) {
  565. let type = checkList[i];
  566. let typeName = type.name;
  567. if (id == type.id && !type.itemId&&typeName!=='特殊车辆'&&typeName!=='干杂货人工装卸') {
  568. sa.error('选择[' + this.m.goodsName + ']时,[' + typeName + ']必选')
  569. return;
  570. }
  571. if(!chechItem&&this.m.goodsName=='干杂货'){
  572. sa.error('请选择特殊车辆或干杂货人工装卸之一')
  573. return;
  574. }
  575. }
  576. }
  577. let typeList = this.itemTypeList.filter(obj => obj.itemId);
  578. let list = [];
  579. if (typeList.length == 0) {
  580. sa.error('至少选择一项业务');
  581. return false;
  582. }
  583. for (let i in typeList) {
  584. let type = typeList[i];
  585. list.push({
  586. itemId: type.itemId,
  587. num: type.num
  588. })
  589. }
  590. if (typeList.filter(obj => obj.name.indexOf('人') !== -1 && obj.name.indexOf('核酸') !== -1)
  591. .length > 0 &&
  592. this.modal.list
  593. .length == 0) {
  594. sa.error('请添加核酸检测人员');
  595. return false;
  596. }
  597. m.itemJson = JSON.stringify(list);
  598. m.peopleJson = JSON.stringify(this.modal.list);
  599. m.carJson = JSON.stringify(this.china.list);
  600. m.items = [];
  601. m.cars = [];
  602. sa.ajax('/TbBusiness/add', m, function(res) {
  603. sa.alert('增加成功', this.clean);
  604. }.bind(this));
  605. },
  606. // 添加/修改 完成后的动作
  607. clean: function() {
  608. this.modal.list = [];
  609. if (this.id == 0) {
  610. this.m = this.createModel();
  611. } else {
  612. parent.app.f5(); // 刷新父页面列表
  613. sa.closeCurrIframe(); // 关闭本页
  614. }
  615. }
  616. },
  617. mounted: function() {
  618. this.getCustomer();
  619. this.getItemTypeList();
  620. this.getGoods();
  621. this.getUnitList();
  622. }
  623. })
  624. </script>
  625. </body>
  626. </html>