tb-business-add.html 15 KB

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