tb-business-add.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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)">操作</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" v-if="modal.list.length<modal.num">添加
  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="姓名" placeholder="姓名" v-model="addModal.form.name" br></sa-item>
  171. <sa-item type="text" name="联系号码" placeholder="联系号码" 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. filterTypeList: [],
  212. goodsList: [],
  213. countryList: [{
  214. name: '越南车'
  215. }, {
  216. name: '中国车'
  217. }],
  218. tableData: [],
  219. modal: {
  220. visible: false,
  221. itemId: 4,
  222. num: 1,
  223. list: []
  224. },
  225. addModal: {
  226. visible: false,
  227. form: {
  228. name: '',
  229. phone: '',
  230. itemId: 4,
  231. ticket: ''
  232. }
  233. },
  234. unitList: [],
  235. needTypeId: []
  236. },
  237. computed: {
  238. totalPrice() {
  239. let itemList = this.itemTypeList.filter(obj => obj.itemId);
  240. let price = 0;
  241. for (let i in itemList) {
  242. let type = itemList[i];
  243. let num = type.num;
  244. let items = type.items;
  245. for (let j in items) {
  246. let item = items[j];
  247. if (item.id == type.itemId) {
  248. price += num * item.price;
  249. break;
  250. }
  251. }
  252. }
  253. return price;
  254. }
  255. },
  256. methods: {
  257. goodsChange(value) {
  258. let goods = this.goodsList.filter(obj => obj.name === value).pop();
  259. let noNeedIds = goods.noNeedIds.split(',');
  260. this.needTypeId = goods.needIds.split(',');
  261. this.filterTypeList = this.itemTypeList.filter(type => noNeedIds.indexOf(type.id) === -1);
  262. },
  263. getUnitList() {
  264. sa.ajax('/TbUnit/getList', {
  265. pageNo: 1,
  266. pageSize: 50
  267. }, function(resp) {
  268. this.unitList = resp.data;
  269. }.bind(this))
  270. },
  271. addPeopleFn(itemId, num) {
  272. this.modal.itemId = itemId;
  273. this.modal.num = num;
  274. this.modal.visible = true;
  275. },
  276. showAddModal() {
  277. Object.assign(this.addModal, {
  278. visible: true,
  279. form: {
  280. index: -1,
  281. name: '',
  282. phone: '',
  283. itemId: this.modal.itemId,
  284. ticket: ''
  285. }
  286. })
  287. },
  288. cancelAdd() {
  289. this.modal.list = [];
  290. this.modal.visible = false;
  291. },
  292. confirmAdd() {
  293. if (!this.addModal.form.name) {
  294. sa.error('请输入检测人姓名')
  295. return false;
  296. }
  297. let phone = this.addModal.form.phone;
  298. if (phone && !sa.isPhone(phone)) {
  299. sa.error('检测人联系号码不正确')
  300. return false;
  301. }
  302. let dbIndex = this.addModal.form.index;
  303. if (dbIndex >= 0) {
  304. this.modal.list[dbIndex].name = this.addModal.form.name;
  305. this.modal.list[dbIndex].phone = this.addModal.form.phone;
  306. } else {
  307. this.addModal.form.index = this.modal.list.length;
  308. this.modal.list.push(this.addModal.form);
  309. }
  310. this.addModal.visible = false;
  311. },
  312. editFn(data) {
  313. Object.assign(this.addModal, {
  314. visible: true,
  315. form: data
  316. })
  317. },
  318. deleteFn(data) {
  319. this.modal.list.splice(data.index, 1);
  320. if (data.id) {
  321. sa.ajax('/TbBusinessPeople/deleteById', {
  322. id: data.id
  323. }, function(resp) {
  324. }.bind(this))
  325. }
  326. },
  327. getGoods() {
  328. sa.ajax('/TbGoods/getList', {
  329. pageNo: 1,
  330. pageSize: 10
  331. }, function(resp) {
  332. this.goodsList = resp.data;
  333. }.bind(this))
  334. },
  335. getItemTypeList() {
  336. sa.ajax('/TbItemType/getList', function(resp) {
  337. let typeList = resp.data;
  338. // 初始化数据
  339. if (this.id > 0) {
  340. sa.ajax('/TbBusiness/getById?id=' + this.id, function(res) {
  341. let m = res.data;
  342. let items = m.items;
  343. for (let i in items) {
  344. let item = items[i];
  345. for (let j in typeList) {
  346. let type = typeList[j];
  347. if (item.itemTypeId == type.id) {
  348. type.itemId = item.itemId;
  349. type.num = item.num;
  350. }
  351. }
  352. }
  353. this.m = m;
  354. }.bind(this))
  355. }
  356. this.itemTypeList = typeList;
  357. }.bind(this))
  358. },
  359. queryCaSizerAsync(queryStr, cb) {
  360. let list = this.unitList;
  361. let filterList = list.filter(obj => obj.unit.indexOf(queryStr) !== -1);
  362. cb(filterList)
  363. },
  364. handleSelectCarSize(item) {
  365. this.m.cardSize = item.unit;
  366. },
  367. getCustomerList() {
  368. sa.ajax('/TbCostomer/getList', {
  369. pageNo: 1,
  370. pageSize: 100,
  371. judgeStatus: 2
  372. }, function(resp) {
  373. this.customerList = resp.data;
  374. if (resp.data.length > 0) {
  375. this.m.customerId = resp.data[0].id;
  376. }
  377. }.bind(this));
  378. },
  379. getCustomer() {
  380. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  381. let id = resp.data;
  382. if (id == 1) {
  383. this.getCustomerList();
  384. } else {
  385. this.m.customerId = id;
  386. }
  387. this.currentCustomerId = id;
  388. }.bind(this));
  389. },
  390. // 提交数据
  391. ok: function() {
  392. // 表单校验
  393. let m = this.m;
  394. if (this.currentCustomerId == 1) {
  395. sa.checkNull(m.customerId, '请选择 [客户名称]');
  396. }
  397. sa.checkNull(m.goodsName, '请选择运输货物');
  398. sa.checkNull(m.cardNo, '请输入 [车牌号]');
  399. if (!sa.isNum(m.cardSize)) {
  400. sa.error('车辆规格只能输入数字')
  401. return;
  402. }
  403. if (!sa.isNum(m.netWeight)) {
  404. sa.error('载重只能输入数字')
  405. return;
  406. }
  407. sa.checkNull(m.driverName, '请输入 [中国司机名称]');
  408. if (!sa.isPhone(m.driverPhone)) {
  409. sa.error('司机联系号码不正确')
  410. return false;
  411. }
  412. sa.checkNull(m.chinaCarNo, '请输入 [中国车牌号]');
  413. let checkList = this.itemTypeList;
  414. for (let j in this.needTypeId) {
  415. let id = this.needTypeId[j];
  416. for (let i in checkList) {
  417. let type = checkList[i];
  418. if (id == type.id && !type.itemId) {
  419. sa.error('选择[' + this.m.goodsName + ']时,[' + type.name + ']必选')
  420. return;
  421. }
  422. }
  423. }
  424. let typeList = this.itemTypeList.filter(obj => obj.itemId);
  425. let list = [];
  426. if (typeList.length == 0) {
  427. sa.error('至少选择一项业务');
  428. return false;
  429. }
  430. for (let i in typeList) {
  431. let type = typeList[i];
  432. list.push({
  433. itemId: type.itemId,
  434. num: type.num
  435. })
  436. }
  437. if (typeList.filter(obj => obj.name.indexOf('人')!==-1&&obj.name.indexOf('核酸')!==-1).length > 0
  438. && this.modal.list
  439. .length == 0) {
  440. sa.error('请添加核酸检测人员');
  441. return false;
  442. }
  443. m.itemJson = JSON.stringify(list);
  444. m.peopleJson = JSON.stringify(this.modal.list);
  445. m.items = [];
  446. if (this.id <= 0) { // 添加
  447. sa.ajax('/TbBusiness/add', m, function(res) {
  448. sa.alert('增加成功', this.clean);
  449. }.bind(this));
  450. } else { // 修改
  451. sa.ajax('/TbBusiness/update', m, function(res) {
  452. sa.alert('修改成功', this.clean);
  453. }.bind(this));
  454. }
  455. },
  456. // 添加/修改 完成后的动作
  457. clean: function() {
  458. this.modal.list = [];
  459. if (this.id == 0) {
  460. this.m = this.createModel();
  461. } else {
  462. parent.app.f5(); // 刷新父页面列表
  463. sa.closeCurrIframe(); // 关闭本页
  464. }
  465. }
  466. },
  467. mounted: function() {
  468. this.getCustomer();
  469. this.getItemTypeList();
  470. this.getGoods();
  471. this.getUnitList();
  472. }
  473. })
  474. </script>
  475. </body>
  476. </html>