tb-business-edit.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  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="请输入车辆载重" v-model="m.netWeight" br>
  73. </sa-item>
  74. <div class="c-item">
  75. <label class="c-label">境外车牌号:</label>
  76. <el-input v-model="m.cardNo" readonly disabled placeholder="请输入境外车牌号">
  77. </el-input>
  78. </div>
  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. </el-autocomplete>
  96. </div>
  97. </div>
  98. </el-card>
  99. </el-col>
  100. <el-col span=14>
  101. <el-card class="box-card">
  102. <div slot="header" class="clearfix">
  103. <span>业务项</span>
  104. </div>
  105. <div>
  106. <el-form-item v-for="(type,index) in filterTypeList" style="display: flex;"
  107. v-if="filterTypeList.length>0">
  108. <label slot="label"><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" v-if="m.netWeight >= item.minWeight && m.netWeight < item.maxWeight
  113. &&m.cardSize<=item.carLength&&m.cardSize>=item.minLength" :key="item.id" :label="item.itemName"
  114. :value="item.id">
  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,true)">操作</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()" v-if="sa.isAuth('tb-business-edit')">确定</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="1" :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. findInAndNoBusinessCar(){
  339. sa.ajax('/TbBusinessCar/findInAndNoBusinessCar',function(resp){
  340. this.carList=resp.data;
  341. }.bind(this))
  342. },
  343. handleSelectCar(data){
  344. this.m.cardNo=data.carNo;
  345. this.m.cardSize=data.carSize;
  346. },
  347. queryCarAsync(queryStr,cb){
  348. let list = this.carList;
  349. let filterList = list.filter(obj => obj.carNo.indexOf(queryStr) !== -1);
  350. cb(filterList)
  351. },
  352. handleSelectChinaCar(data){
  353. this.car.form.carNo=data.carNo;
  354. this.car.form.cardSize=data.carSize;
  355. },
  356. queryChinaCarAsync(queryStr,cb){
  357. let list = this.carList;
  358. let filterList = list.filter(obj => obj.carNo.indexOf(queryStr) !== -1&&obj.carNo!==this.m.cardNo);
  359. cb(filterList)
  360. },
  361. cleanItem(type) {
  362. type.itemId = '';
  363. let typeName = type.name;
  364. if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
  365. this.checkItem = '';
  366. }
  367. },
  368. itemChange(itemId) {
  369. let items = this.itemTypeList.flatMap(obj => obj.items);
  370. let item = items.filter(obj => obj.id == itemId)[0];
  371. let typeName = item.typeName;
  372. let checkItem = this.checkItem;
  373. if ((typeName == '干杂货人工装卸' && checkItem == '特殊车辆') ||
  374. (typeName == '特殊车辆' && checkItem == '干杂货人工装卸')) {
  375. this.itemTypeList.filter(obj => obj.id == item.typeId)[0].itemId = ''
  376. sa.error('不能同时选择干杂货人工装卸和特殊车辆')
  377. return false;
  378. }
  379. if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
  380. this.checkItem = typeName;
  381. }
  382. },
  383. addCar() {
  384. this.china.visible = true;
  385. },
  386. addChinaCarFn() {
  387. Object.assign(this.car, {
  388. visible: true,
  389. form: {
  390. carNo: '',
  391. driverName: '',
  392. driverPhone: '',
  393. carSize: ''
  394. }
  395. })
  396. },
  397. confirmAddCar() {
  398. let carNo = this.car.form.carNo;
  399. if (!sa.isCarNo(carNo)) {
  400. sa.error('请填入正确的车牌号')
  401. return false;
  402. }
  403. if (!this.car.form.carSize) {
  404. sa.error('请填入车辆规格')
  405. return false;
  406. }
  407. let phone = this.car.form.phone;
  408. if (phone && !sa.isPhone(phone)) {
  409. sa.error('联系号码不正确')
  410. return false;
  411. }
  412. let list = this.china.list;
  413. let index = list.map(obj => obj.carNo).indexOf(carNo);
  414. if (index > -1) {
  415. list.splice(index, 1);
  416. }
  417. this.china.list.push(this.car.form);
  418. this.car.visible = false;
  419. },
  420. editChinaCarFn(data) {
  421. Object.assign(this.car, {
  422. visible: true,
  423. form: data
  424. })
  425. },
  426. deleteChinaCarFn(data) {
  427. this.china.list.splice(this.china.list.indexOf(data), 1)
  428. },
  429. goodsChange(value) {
  430. let goods = this.goodsList.filter(obj => obj.name === value).pop();
  431. let noNeedIds = goods.noNeedIds.split(',');
  432. this.needTypeId = goods.needIds.split(',');
  433. this.filterTypeList = this.itemTypeList.filter(type => noNeedIds.indexOf(type.id) === -1);
  434. },
  435. getUnitList() {
  436. sa.ajax('/TbUnit/getList', {
  437. pageNo: 1,
  438. pageSize: 50
  439. }, function(resp) {
  440. this.unitList = resp.data;
  441. }.bind(this))
  442. },
  443. addPeopleFn(itemId, num, show) {
  444. sa.ajax('/TbBusinessPeople/getList', {
  445. businessId: this.id
  446. }, function(resp) {
  447. let list = resp.data;
  448. let index = 0;
  449. let r = [];
  450. for (let i in list) {
  451. r.push({
  452. name: list[i].name,
  453. phone: list[i].phone,
  454. index: index,
  455. id: list[i].id
  456. })
  457. index++;
  458. }
  459. this.modal.list = r;
  460. }.bind(this));
  461. this.modal.itemId = itemId;
  462. this.modal.num = num;
  463. this.modal.visible = show;
  464. },
  465. showAddModal() {
  466. Object.assign(this.addModal, {
  467. visible: true,
  468. form: {
  469. index: -1,
  470. name: '',
  471. phone: '',
  472. itemId: this.modal.itemId,
  473. ticket: ''
  474. }
  475. })
  476. },
  477. cancelAdd() {
  478. this.modal.list = [];
  479. this.modal.visible = false;
  480. },
  481. confirmAdd() {
  482. if (!this.addModal.form.name) {
  483. sa.error('请输入检测人姓名')
  484. return false;
  485. }
  486. let phone = this.addModal.form.phone;
  487. if (phone && !sa.isPhone(phone)) {
  488. sa.error('检测人联系号码不正确')
  489. return false;
  490. }
  491. let dbIndex = this.addModal.form.index;
  492. if (dbIndex >= 0) {
  493. this.modal.list[dbIndex].name = this.addModal.form.name;
  494. this.modal.list[dbIndex].phone = this.addModal.form.phone;
  495. } else {
  496. this.addModal.form.index = this.modal.list.length;
  497. this.modal.list.push(this.addModal.form);
  498. }
  499. this.addModal.visible = false;
  500. },
  501. editFn(data) {
  502. Object.assign(this.addModal, {
  503. visible: true,
  504. form: data
  505. })
  506. },
  507. deleteFn(data) {
  508. this.modal.list.splice(data.index, 1);
  509. if (data.id) {
  510. sa.ajax('/TbBusinessPeople/deleteById', {
  511. id: data.id
  512. }, function(resp) {
  513. }.bind(this))
  514. }
  515. },
  516. getGoods() {
  517. sa.ajax('/TbGoods/getList', {
  518. pageNo: 1,
  519. pageSize: 10
  520. }, function(resp) {
  521. this.goodsList = resp.data;
  522. }.bind(this))
  523. },
  524. getItemTypeList() {
  525. sa.ajax('/TbItemType/getList', function(resp) {
  526. let typeList = resp.data;
  527. // 初始化数据
  528. sa.ajax('/TbBusiness/getById?id=' + this.id, function(res) {
  529. let m = res.data;
  530. let items = m.items;
  531. this.china.list = m.cars.filter(obj=>obj.carNo!==m.cardNo);
  532. let hsItem = items.filter(obj => obj.itemTypeName.indexOf('人') !== -1 &&
  533. obj.itemTypeName.indexOf('核酸') !== -1);
  534. if (hsItem.length > 0) {
  535. this.addPeopleFn(hsItem[0].itemTypeId, false)
  536. }
  537. for (let i in items) {
  538. let item = items[i];
  539. if (item.itemTypeName == '特殊车辆' || item.itemTypeName == '干杂货人工装卸') {
  540. this.checkItem = item.itemTypeName
  541. }
  542. for (let j in typeList) {
  543. let type = typeList[j];
  544. if (item.itemTypeId == type.id) {
  545. type.itemId = item.itemId;
  546. type.num = item.num;
  547. }
  548. }
  549. }
  550. this.m = m;
  551. this.itemTypeList = typeList;
  552. this.goodsChange(m.goodsName);
  553. }.bind(this))
  554. }.bind(this))
  555. },
  556. queryCaSizerAsync(queryStr, cb) {
  557. let list = this.unitList;
  558. let filterList = list.filter(obj => obj.unit.indexOf(queryStr) !== -1);
  559. cb(filterList)
  560. },
  561. handleSelectCarSize(item) {
  562. this.m.cardSize = item.unit;
  563. },
  564. getCustomerList() {
  565. sa.ajax('/TbCostomer/getList', {
  566. pageNo: 1,
  567. pageSize: 100,
  568. judgeStatus: 2,
  569. type:0
  570. }, function(resp) {
  571. this.customerList = resp.data;
  572. if (resp.data.length > 0) {
  573. this.m.customerId = resp.data[0].id;
  574. }
  575. }.bind(this));
  576. },
  577. getCustomer() {
  578. sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
  579. let id = resp.data;
  580. if (id == 1) {
  581. this.getCustomerList();
  582. } else {
  583. this.m.customerId = id;
  584. }
  585. this.currentCustomerId = id;
  586. }.bind(this));
  587. },
  588. closeFn() {
  589. parent.app.f5();
  590. sa.closeCurrIframe();
  591. },
  592. // 提交数据
  593. ok: function() {
  594. // 表单校验
  595. let m = this.m;
  596. if (this.currentCustomerId == 1) {
  597. sa.checkNull(m.customerId, '请选择 [客户名称]');
  598. }
  599. sa.checkNull(m.goodsName, '请选择运输货物');
  600. sa.checkNull(m.cardNo, '请输入 [车牌号]');
  601. if (!m.cardSize||!sa.isNum(m.cardSize)) {
  602. sa.error('车辆规格只能输入数字')
  603. return;
  604. }
  605. if (!sa.isNum(m.netWeight)) {
  606. sa.error('载重只能输入数字')
  607. return;
  608. }
  609. let checkList = this.itemTypeList;
  610. let chechItem = this.checkItem;
  611. for (let j in this.needTypeId) {
  612. let id = this.needTypeId[j];
  613. for (let i in checkList) {
  614. let type = checkList[i];
  615. let typeName = type.name;
  616. if (id == type.id && !type.itemId && typeName !== '特殊车辆' && typeName !== '干杂货人工装卸') {
  617. sa.error('选择[' + this.m.goodsName + ']时,[' + typeName + ']必选')
  618. return;
  619. }
  620. if (!chechItem && this.m.goodsName == '干杂货') {
  621. sa.error('请选择特殊车辆或干杂货人工装卸之一')
  622. return;
  623. }
  624. }
  625. }
  626. let typeList = this.itemTypeList.filter(obj => obj.itemId);
  627. let list = [];
  628. if (typeList.length == 0) {
  629. sa.error('至少选择一项业务');
  630. return false;
  631. }
  632. for (let i in typeList) {
  633. let type = typeList[i];
  634. list.push({
  635. itemId: type.itemId,
  636. num: type.num
  637. })
  638. }
  639. if (typeList.filter(obj => obj.name.indexOf('人') !== -1 && obj.name.indexOf('核酸') !== -1)
  640. .length > 0 &&
  641. this.modal.list
  642. .length == 0) {
  643. sa.error('请添加核酸检测人员');
  644. return false;
  645. }
  646. m.itemJson = JSON.stringify(list);
  647. m.peopleJson = JSON.stringify(this.modal.list);
  648. m.carJson = JSON.stringify(this.china.list);
  649. m.items = [];
  650. m.cars = [];
  651. if (this.id <= 0) { // 添加
  652. sa.ajax('/TbBusiness/add', m, function(res) {
  653. sa.alert('增加成功', this.clean);
  654. }.bind(this));
  655. } else { // 修改
  656. sa.ajax('/TbBusiness/update', m, function(res) {
  657. sa.alert('修改成功', this.clean);
  658. }.bind(this));
  659. }
  660. },
  661. // 添加/修改 完成后的动作
  662. clean: function() {
  663. parent.app.f5(); // 刷新父页面列表
  664. this.modal.list = [];
  665. if (this.id == 0) {
  666. this.m = this.createModel();
  667. } else {
  668. sa.closeCurrIframe(); // 关闭本页
  669. }
  670. }
  671. },
  672. mounted: function() {
  673. this.getCustomer();
  674. this.getItemTypeList();
  675. this.getGoods();
  676. this.getUnitList();
  677. },
  678. beforeDestroy() {
  679. parent.app.f5();
  680. }
  681. })
  682. </script>
  683. </body>
  684. </html>