tb-business-add.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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"><span style="color: red;">*</span>选择客户:</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"><span style="color: red;">*</span>运输货品:</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="请输入车辆载重"
  73. v-model="m.netWeight" br>
  74. </sa-item>
  75. <sa-item type="text" name="境外车牌号" placeholder="请输入境外车牌号" v-model="m.cardNo" br>
  76. </sa-item>
  77. </sa-item>
  78. <div class="c-item">
  79. <label class="c-label"><span style="color: red;">*</span>境外车规格:</label>
  80. <el-autocomplete v-model="m.cardSize" placeholder="请输入车规格"
  81. @select="handleSelectCarSize" value-key='unit'
  82. :fetch-suggestions="queryCaSizerAsync">
  83. </el-autocomplete>
  84. </div>
  85. <sa-item type="text" name="中国车牌" placeholder="请输入中国车牌" v-model="m.chinaCarNo"
  86. br></sa-item>
  87. <sa-item type="text" name="中国司机" placeholder="请输入中国车司机" v-model="m.driverName"
  88. br></sa-item>
  89. <sa-item type="text" name="联系号码" placeholder="请输入联系号码" v-model="m.driverPhone"
  90. br></sa-item>
  91. <sa-item type="datetime" name="预计入场" placeholder="请选择" v-model="m.expectInDay"
  92. br></sa-item>
  93. </div>
  94. </el-card>
  95. </el-col>
  96. <el-col span=14>
  97. <el-card class="box-card">
  98. <div slot="header" class="clearfix">
  99. <span>业务项</span>
  100. </div>
  101. <div>
  102. <el-form-item v-for="(type,index) in filterTypeList" style="display: flex;"
  103. v-if="filterTypeList.length>0">
  104. <label slot="label"><label v-if="needTypeId.indexOf(type.id)!==-1"
  105. style="color: red;">*</label>{{type.name}}</label>
  106. <el-select v-model="type.itemId" style="width: 120px;" placeholder="请选择">
  107. <el-option v-for="item in type.items" :key="item.id" :label="item.itemName" :value="item.id"
  108. v-if="m.netWeight >= item.minWeight && m.netWeight < item.maxWeight
  109. &&m.cardSize<=item.carLength&&m.cardSize>=item.minLength">
  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)">操作</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) {
  275. this.modal.itemId = itemId;
  276. this.modal.num = num;
  277. this.modal.visible = true;
  278. },
  279. showAddModal() {
  280. Object.assign(this.addModal, {
  281. visible: true,
  282. form: {
  283. index: -1,
  284. name: '',
  285. phone: '',
  286. itemId: this.modal.itemId,
  287. ticket: ''
  288. }
  289. })
  290. },
  291. cancelAdd() {
  292. this.modal.list = [];
  293. this.modal.visible = false;
  294. },
  295. confirmAdd() {
  296. if (!this.addModal.form.name) {
  297. sa.error('请输入检测人姓名')
  298. return false;
  299. }
  300. let phone = this.addModal.form.phone;
  301. if (phone && !sa.isPhone(phone)) {
  302. sa.error('检测人联系号码不正确')
  303. return false;
  304. }
  305. let dbIndex = this.addModal.form.index;
  306. if (dbIndex >= 0) {
  307. this.modal.list[dbIndex].name = this.addModal.form.name;
  308. this.modal.list[dbIndex].phone = this.addModal.form.phone;
  309. } else {
  310. this.addModal.form.index = this.modal.list.length;
  311. this.modal.list.push(this.addModal.form);
  312. }
  313. this.addModal.visible = false;
  314. },
  315. editFn(data) {
  316. Object.assign(this.addModal, {
  317. visible: true,
  318. form: data
  319. })
  320. },
  321. deleteFn(data) {
  322. this.modal.list.splice(data.index, 1);
  323. if (data.id) {
  324. sa.ajax('/TbBusinessPeople/deleteById', {
  325. id: data.id
  326. }, function(resp) {
  327. }.bind(this))
  328. }
  329. },
  330. getGoods() {
  331. sa.ajax('/TbGoods/getList', {
  332. pageNo: 1,
  333. pageSize: 10
  334. }, function(resp) {
  335. this.goodsList = resp.data;
  336. }.bind(this))
  337. },
  338. getItemTypeList() {
  339. sa.ajax('/TbItemType/getList', function(resp) {
  340. let typeList = resp.data;
  341. // 初始化数据
  342. if (this.id > 0) {
  343. sa.ajax('/TbBusiness/getById?id=' + this.id, function(res) {
  344. let m = res.data;
  345. let items = m.items;
  346. for (let i in items) {
  347. let item = items[i];
  348. for (let j in typeList) {
  349. let type = typeList[j];
  350. if (item.itemTypeId == type.id) {
  351. type.itemId = item.itemId;
  352. type.num = item.num;
  353. }
  354. }
  355. }
  356. this.m = m;
  357. }.bind(this))
  358. }
  359. this.itemTypeList = typeList;
  360. }.bind(this))
  361. },
  362. queryCaSizerAsync(queryStr, cb) {
  363. let list = this.unitList;
  364. let filterList = list.filter(obj => obj.unit.indexOf(queryStr) !== -1);
  365. cb(filterList)
  366. },
  367. handleSelectCarSize(item) {
  368. this.m.cardSize = item.unit;
  369. },
  370. getCustomerList() {
  371. sa.ajax('/TbCostomer/getList', {
  372. pageNo: 1,
  373. pageSize: 100,
  374. judgeStatus: 2
  375. }, function(resp) {
  376. this.customerList = resp.data;
  377. if (resp.data.length > 0) {
  378. this.m.customerId = resp.data[0].id;
  379. }
  380. }.bind(this));
  381. },
  382. getCustomer() {
  383. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  384. let id = resp.data;
  385. if (id == 1) {
  386. this.getCustomerList();
  387. } else {
  388. this.m.customerId = id;
  389. }
  390. this.currentCustomerId = id;
  391. }.bind(this));
  392. },
  393. closeFn() {
  394. parent.app.f5();
  395. sa.closeCurrIframe();
  396. },
  397. // 提交数据
  398. ok: function() {
  399. // 表单校验
  400. let m = this.m;
  401. if (this.currentCustomerId == 1) {
  402. sa.checkNull(m.customerId, '请选择 [客户名称]');
  403. }
  404. sa.checkNull(m.goodsName, '请选择运输货物');
  405. sa.checkNull(m.cardNo, '请输入 [车牌号]');
  406. if (!sa.isNum(m.cardSize)) {
  407. sa.error('车辆规格只能输入数字')
  408. return;
  409. }
  410. if (!sa.isNum(m.netWeight)) {
  411. sa.error('载重只能输入数字')
  412. return;
  413. }
  414. sa.checkNull(m.driverName, '请输入 [中国司机名称]');
  415. if (!sa.isPhone(m.driverPhone)) {
  416. sa.error('司机联系号码不正确')
  417. return false;
  418. }
  419. sa.checkNull(m.chinaCarNo, '请输入 [中国车牌号]');
  420. let checkList = this.itemTypeList;
  421. for (let j in this.needTypeId) {
  422. let id = this.needTypeId[j];
  423. for (let i in checkList) {
  424. let type = checkList[i];
  425. if (id == type.id && !type.itemId) {
  426. sa.error('选择[' + this.m.goodsName + ']时,[' + type.name + ']必选')
  427. return;
  428. }
  429. }
  430. }
  431. let typeList = this.itemTypeList.filter(obj => obj.itemId);
  432. let list = [];
  433. if (typeList.length == 0) {
  434. sa.error('至少选择一项业务');
  435. return false;
  436. }
  437. for (let i in typeList) {
  438. let type = typeList[i];
  439. list.push({
  440. itemId: type.itemId,
  441. num: type.num
  442. })
  443. }
  444. if (typeList.filter(obj => obj.name.indexOf('人') !== -1 && obj.name.indexOf('核酸') !== -1)
  445. .length > 0 &&
  446. this.modal.list
  447. .length == 0) {
  448. sa.error('请添加核酸检测人员');
  449. return false;
  450. }
  451. m.itemJson = JSON.stringify(list);
  452. m.peopleJson = JSON.stringify(this.modal.list);
  453. m.items = [];
  454. if (this.id <= 0) { // 添加
  455. sa.ajax('/TbBusiness/add', m, function(res) {
  456. sa.alert('增加成功', this.clean);
  457. }.bind(this));
  458. } else { // 修改
  459. sa.ajax('/TbBusiness/update', m, function(res) {
  460. sa.alert('修改成功', this.clean);
  461. }.bind(this));
  462. }
  463. },
  464. // 添加/修改 完成后的动作
  465. clean: function() {
  466. this.modal.list = [];
  467. if (this.id == 0) {
  468. this.m = this.createModel();
  469. } else {
  470. parent.app.f5(); // 刷新父页面列表
  471. sa.closeCurrIframe(); // 关闭本页
  472. }
  473. }
  474. },
  475. mounted: function() {
  476. this.getCustomer();
  477. this.getItemTypeList();
  478. this.getGoods();
  479. this.getUnitList();
  480. }
  481. })
  482. </script>
  483. </body>
  484. </html>