business-entering.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. <template>
  2. <view>
  3. <view class="box" v-show="hs.visible">
  4. <view class="top">
  5. <text class="title">录入核酸人员</text>
  6. </view>
  7. <view style="display: flex;margin-top: 40rpx;">
  8. <u-button type="primary" @click="hs.visible=false" text="返回" style="width: 20px;" size="mini" />
  9. <u-button type="primary" @click="showHsModal" text="添加" v-show="hs.num>hs.list.length" icon="plus"
  10. style="width: 20px;" size="mini" />
  11. </view>
  12. <u-row style="margin-top: 70rpx;">
  13. <u-col span="4" style="text-align: center;">姓名</u-col>
  14. <u-col span="4" style="text-align: center;">联系号码</u-col>
  15. <u-col span="4" style="text-align: center;">操作</u-col>
  16. </u-row>
  17. <u-row v-for="item in hs.list" style="margin-top: 40rpx;">
  18. <u-col span="4" style="text-align: center;">{{item.name}}</u-col>
  19. <u-col span="4" style="text-align: center;">{{item.phone}}</u-col>
  20. <u-col span="4" style="text-align: center;">
  21. <u-row>
  22. <u-col span="6">
  23. <u-button type="primary" text="编辑" style="width: 20px;" @click="editFn(item)" size="mini">
  24. </u-button>
  25. </u-col>
  26. <u-col span="6">
  27. <u-button type="error" style="width: 20px;" text="删除" @click="deleteFn(item)" size="mini">
  28. </u-button>
  29. </u-col>
  30. </u-row>
  31. </u-col>
  32. </u-row>
  33. </view>
  34. <view class="box" v-show="china.visible">
  35. <view class="top">
  36. <text class="title">中国车录入</text>
  37. </view>
  38. <view style="display: flex;margin-top: 40rpx;">
  39. <u-button type="primary" @click="china.visible=false" text="返回" style="width: 20px;" size="mini" />
  40. <u-button type="primary" @click="showChinaModal" text="添加" icon="plus" style="width: 20px;"
  41. size="mini" />
  42. </view>
  43. <u-row style="margin-top: 70rpx;">
  44. <u-col span="3" style="text-align: center;">车牌号</u-col>
  45. <u-col span="3" style="text-align: center;">联系人</u-col>
  46. <u-col span="3" style="text-align: center;">联系号码</u-col>
  47. <u-col span="3" style="text-align: center;">操作</u-col>
  48. </u-row>
  49. <u-row v-for="(item,index) in china.list" style="margin-top: 40rpx;">
  50. <u-col span="3" style="text-align: center;">{{item.carNo}}</u-col>
  51. <u-col span="3" style="text-align: center;">{{item.driverName}}</u-col>
  52. <u-col span="3" style="text-align: center;">{{item.driverPhone}}</u-col>
  53. <u-col span="3" style="text-align: center;">
  54. <u-row>
  55. <u-col span="6">
  56. <u-button type="primary" text="编辑" style="width: 20px;" @click="editChinaCar(item,index)"
  57. size="mini">
  58. </u-button>
  59. </u-col>
  60. <u-col span="6">
  61. <u-button type="error" style="width: 20px;" text="删除" @click="deleteChinaCar(item,index)"
  62. size="mini">
  63. </u-button>
  64. </u-col>
  65. </u-row>
  66. </u-col>
  67. </u-row>
  68. </view>
  69. <view class="box" v-show="!hs.visible&&!china.visible">
  70. <view class="top">
  71. <text class="title">业务录入</text>
  72. </view>
  73. <view class="item" v-show="customerId=='1'">
  74. <view class="l"><text style="color: red;">*</text>企业名称:</view>
  75. <view class="r">
  76. <picker v-if="customer.customerList.length>0" class="p-picker" id="qy"
  77. @change="bindPickerChange($event)" :value="customer.index" :range="customer.customerList"
  78. range-key="name">
  79. <text class="p-text">{{customer.customerList[customer.index].name}}</text>
  80. <u-icon class="p-icon" name="arrow-down-fill" size="20"></u-icon>
  81. </picker>
  82. </view>
  83. </view>
  84. <view class="item">
  85. <view class="l"><text style="color: red;">*</text>申报单号:</view>
  86. <view class="r">
  87. <u-input placeholder="申报订单号" v-model="form.declareNo" clearable readonly>
  88. <text slot="suffix" style="font-size: 50rpx;" @click="selectDeclare">+</text>
  89. </u-input>
  90. </view>
  91. </view>
  92. <view class="item">
  93. <view class="l"><text style="color: red;">*</text>货物:</view>
  94. <view class="r">
  95. <picker v-if="goods.goodsList.length>0" class="p-picker" id="hw" @change="whChange($event)"
  96. :value="goods.index" :range="goods.goodsList" range-key="name">
  97. <text class="p-text">{{goods.goodsList[goods.index].name}}</text>
  98. <u-icon class="p-icon" name="arrow-down-fill" size="20"></u-icon>
  99. </picker>
  100. </view>
  101. </view>
  102. <view class="item">
  103. <view class="l"><text style="color: red;">*</text>载重:</view>
  104. <view class="r">
  105. <u-input type="number" placeholder="输入载重" @input="handler()" v-model="form.netWeight">
  106. <text slot="suffix">吨</text>
  107. </u-input>
  108. </view>
  109. </view>
  110. <view class="item">
  111. <view class="l"><text style="color: red;">*</text>境外车牌:</view>
  112. <view class="r">
  113. <u-input placeholder="输入车牌号" @input="handler()" v-model="form.cardNo" />
  114. </view>
  115. </view>
  116. <view class="item">
  117. <view class="l"><text style="color: red;">*</text>境外车规格:</view>
  118. <view class="r">
  119. <u-input type="number" placeholder="输入车辆规格" @input="handler()" v-model="form.cardSize">
  120. <text slot="suffix">米</text>
  121. </u-input>
  122. </view>
  123. </view>
  124. <view class="item">
  125. <view class="l">中国车:</view>
  126. <view class="r">
  127. <u-input placeholder="中国车" v-model="china.list.map(obj=>obj.carNo).join('、')" readonly>
  128. <text slot="suffix" style="font-size: 50rpx;" @click="addCar">+</text>
  129. </u-input>
  130. </view>
  131. </view>
  132. <view class="item-line">
  133. 业务项
  134. </view>
  135. <view class="item" v-for="item in filterItemList" :key="item.id" v-if="item.items.length>0">
  136. <view class="l"><text v-if="needTypeId.indexOf(item.id)!==-1" style="color: red;">*</text>{{item.name}}:
  137. </view>
  138. <view class="r">
  139. <view @click="selectItemFn(item)">
  140. <u-input placeholder="请选择" v-model="item.itemName" readonly clearable style="width: 120px;">
  141. <u-icon name="close" v-if="item.itemName" slot="suffix" color="#E5E5E5;" size="5"
  142. @click="cleanItemSelect(item)"></u-icon>
  143. </u-input>
  144. </view>
  145. <u-input placeholder="数量" :disabled="item.inc==0" border="surround" v-model="item.num" type="number"
  146. style="width: 10px;" v-if="item.itemName"></u-input>
  147. <view style="margin-left: 20rpx;color: red;" v-if="item.itemName">
  148. {{item.items.filter(obj=>obj.itemName==item.itemName)[0].price*item.num}}元
  149. </view>
  150. <u-icon name="plus" style="position: absolute;right: 10rpx;"
  151. v-if="item.itemName&&item.name.indexOf('人')!==-1&&item.name.indexOf('核酸')!==-1"
  152. @click="addHsFn(item.itemName,item.num)"></u-icon>
  153. </view>
  154. </view>
  155. <view class="hj" v-show="totalPrice>0">
  156. 合计:{{totalPrice}}元
  157. </view>
  158. </view>
  159. <u-button type="primary" text="确定" @click="saveFn" v-show="!hs.visible&&!china.visible"></u-button>
  160. <!-- ---------------------------------------------------------- -->
  161. <view class="bottom-safety"></view>
  162. <u-popup :show="car.carInput" :overlay="false" @close="car.carInput=false" borderRadius="10">
  163. <view style="padding: 40rpx;line-height: 60rpx;text-align: center;">
  164. <view v-for="item in filterUnitList" :id="item.id"
  165. style="margin-bottom: 20rpx;border-bottom: 1rpx solid #E5E5E5;" @click="selectCarSize(item)">
  166. {{item.unit}}
  167. </view>
  168. </view>
  169. </u-popup>
  170. <u-popup :show="driver.show" :overlay="false" @close="driver.show=false" borderRadius="10">
  171. <view style="padding: 40rpx;line-height: 60rpx;text-align: center;">
  172. <view v-for="item in driver.filterList" :id="item.id"
  173. style="margin-bottom: 20rpx;border-bottom: 1rpx solid #E5E5E5;" @click="selectDriverFn(item)">
  174. {{item.name}}({{item.idCard}})
  175. </view>
  176. </view>
  177. </u-popup>
  178. <u-popup :show="show" closeable closeOnClickOverlay @close="show=false">
  179. <view style="padding: 40rpx;">
  180. <u-radio-group @change="itemSelectFn" placement="column" v-model="item.itemName">
  181. <u-radio v-for="item in item.items" :key="item.id" :label="item.itemName" :name="item.itemName"
  182. v-if="form.netWeight >= item.minWeight
  183. && form.netWeight < item.maxWeight
  184. &&form.cardSize<=item.carLength
  185. &&form.cardSize>=item.minLength" style="margin-top: 30rpx;">
  186. </u-radio>
  187. </u-radio-group>
  188. </view>
  189. </u-popup>
  190. <u-modal :show="modal.visible" showCancelButton closeOnClickOverlay @cancel="modal.visible=false"
  191. @confirm="addHsPeopleFn">
  192. <view style="">
  193. <u--input placeholder="姓名" border="surround" v-model="modal.form.name"></u--input>
  194. <u--input style="margin-top: 20rpx;" placeholder="联系号码" border="surround" v-model="modal.form.phone">
  195. </u--input>
  196. </view>
  197. </u-modal>
  198. <u-modal :show="chinaAddModal.visible" title="中国车" @confirm="sureCarFn" @cancel="chinaAddModal.visible=false"
  199. showCancelButton cancelText="关闭">
  200. <view class="slot-content">
  201. <u-row>
  202. <u-col span="4">车牌号</u-col>
  203. <u-col span="8">
  204. <u--input placeholder="车牌号" v-model="chinaAddModal.form.carNo"></u--input>
  205. </u-col>
  206. </u-row>
  207. <u-row>
  208. <u-col span="4">联系人</u-col>
  209. <u-col span="8">
  210. <u--input placeholder="联系人" v-model="chinaAddModal.form.driverName"></u--input>
  211. </u-col>
  212. </u-row>
  213. <u-row>
  214. <u-col span="4">联系号码</u-col>
  215. <u-col span="8">
  216. <u--input placeholder="联系号码" v-model="chinaAddModal.form.driverPhone"></u--input>
  217. </u-col>
  218. </u-row>
  219. </view>
  220. </u-modal>
  221. </view>
  222. </template>
  223. <script>
  224. export default {
  225. data() {
  226. return {
  227. car: {
  228. carInput: false,
  229. filterList: [],
  230. },
  231. driver: {
  232. show: false,
  233. filterList: [],
  234. },
  235. customerId: '1',
  236. exprctStart: new Date().getTime(),
  237. itemList: [],
  238. filterItemList: [],
  239. needTypeId: [],
  240. noNeedIds: [],
  241. form: {
  242. customerId: '',
  243. customerIndex: 0,
  244. declareNo: '',
  245. countryIndex: 0,
  246. goodsIndex: 0,
  247. cardNo: '',
  248. cardSize: '',
  249. goodsName: '',
  250. netWeight: '',
  251. driverName: '',
  252. driverPhone: '',
  253. expectInDay: ''
  254. },
  255. show: false,
  256. item: {
  257. items: []
  258. },
  259. customer: {
  260. index: 0,
  261. customerList: [],
  262. },
  263. carList: [],
  264. driverList: [],
  265. unitList: [],
  266. filterUnitList: [],
  267. country: {
  268. index: 0,
  269. list: ['越南车', '中国车']
  270. },
  271. goods: {
  272. index: 0,
  273. goodsList: []
  274. },
  275. hs: {
  276. visible: false,
  277. num: 1,
  278. list: []
  279. },
  280. modal: {
  281. visible: false,
  282. form: {
  283. name: '',
  284. phone: ''
  285. }
  286. },
  287. china: {
  288. visible: false,
  289. index: -1,
  290. list: []
  291. },
  292. chinaAddModal: {
  293. visible: false,
  294. form: {
  295. carNo: '',
  296. driverName: '',
  297. driverPhone: ''
  298. }
  299. },
  300. checkItem: ''
  301. }
  302. },
  303. onShow() {
  304. this.customerId = uni.getStorageSync('customerId');
  305. },
  306. computed: {
  307. totalPrice() {
  308. let itemList = this.itemList.filter(obj => obj.itemName);
  309. let price = 0;
  310. for (let i in itemList) {
  311. let type = itemList[i];
  312. let items = type.items;
  313. for (let j in items) {
  314. let item = items[j];
  315. if (item.itemName == type.itemName) {
  316. price += item.price;
  317. break;
  318. }
  319. }
  320. }
  321. return price;
  322. },
  323. },
  324. created() {
  325. if (this.customerId == '1') {
  326. this.getCustomerList();
  327. }
  328. this.getGoodsList();
  329. this.getUnit();
  330. },
  331. onLoad(options) {
  332. let that = this;
  333. uni.$on('getSelectDeclare', declare => {
  334. that.$nextTick(() => {
  335. that.form.declareNo = declare.declareNo;
  336. that.form.cardNo = declare.carNo;
  337. that.form.chinaCarNo = declare.chinaCarNo;
  338. that.form.netWeight = declare.grossWeight;
  339. let chinaCarNo = declare.chinaCarNo;
  340. if (chinaCarNo) {
  341. let list = [];
  342. chinaCarNo.replace(",", ",").split(",").forEach(carNo => {
  343. let obj = {
  344. carNo: carNo
  345. }
  346. list.push(obj);
  347. that.china.list = list;
  348. })
  349. }else{
  350. that.china.list =[];
  351. }
  352. })
  353. })
  354. },
  355. methods: {
  356. selectDeclare() {
  357. this.$common.to('/pages/business-entering/declare-select?declareNo=' + this.form.declareNo)
  358. },
  359. addCar() {
  360. this.china.visible = true;
  361. },
  362. showChinaModal() {
  363. Object.assign(this.chinaAddModal, {
  364. visible: true,
  365. index: -1,
  366. form: {
  367. carNo: '',
  368. driverName: '',
  369. driverPhone: ''
  370. }
  371. })
  372. },
  373. sureCarFn() {
  374. let form = this.chinaAddModal.form;
  375. let carNo = form.carNo;
  376. let phone = form.driverPhone;
  377. if (carNo && !this.$common.isCarNo(carNo)) {
  378. this.$common.toast('请输入正确的车牌号')
  379. return;
  380. }
  381. if (phone && !this.$common.isPhone(phone)) {
  382. this.$common.toast('请输入正确的手机号')
  383. return;
  384. }
  385. let list = this.china.list;
  386. let index = this.chinaAddModal.index;
  387. if (index > -1) {
  388. list.splice(index, 1)
  389. }
  390. list.push(form)
  391. this.chinaAddModal.visible = false;
  392. },
  393. deleteChinaCar(item, index) {
  394. this.china.list.splice(index, 1);
  395. },
  396. editChinaCar(item, index) {
  397. Object.assign(this.chinaAddModal, {
  398. visible: true,
  399. index: index,
  400. form: item
  401. })
  402. },
  403. whChange(event) {
  404. let index = event.detail.value; //当前picker选中的值
  405. this.goods.index = index;
  406. let goods = this.goods.goodsList[index];
  407. let noNeedIds = goods.noNeedIds.split(',');
  408. this.needTypeId = goods.needIds.split(',');
  409. this.noNeedIds = goods.noNeedIds.split(',')
  410. this.filterItemList = this.itemList.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  411. this.handler();
  412. },
  413. carSizeInput() {
  414. let carSize = this.form.cardSize;
  415. let filterUnitList = this.unitList.filter(obj => obj.unit.indexOf(carSize) !== -1);
  416. this.car.carInput = filterUnitList.length > 0;
  417. this.filterUnitList = filterUnitList;
  418. this.handler();
  419. },
  420. getUnit() {
  421. this.$api.getUnitList().then(resp => {
  422. this.unitList = resp.data;
  423. })
  424. },
  425. selectCarSize(data) {
  426. this.form.cardSize = data.unit;
  427. this.car.carInput = false;
  428. this.handler();
  429. },
  430. expectDayChange(date) {
  431. this.form.expectInDay = date;
  432. this.handler();
  433. },
  434. addHsFn(itemName, num) {
  435. this.hs.visible = true;
  436. this.hs.num = num;
  437. },
  438. showHsModal() {
  439. Object.assign(this.modal, {
  440. visible: true,
  441. form: {
  442. name: '',
  443. phone: '',
  444. index: -1
  445. }
  446. });
  447. },
  448. addHsPeopleFn() {
  449. if (!this.modal.form.name) {
  450. this.$common.toast('请输入名称');
  451. return;
  452. }
  453. if (this.modal.form.phone && !this.$common.isPhone(this.modal.form.phone)) {
  454. this.$common.toast('联系号码不正确');
  455. return;
  456. }
  457. let dbIndex = this.modal.form.index;
  458. if (dbIndex >= 0) {
  459. this.hs.list[dbIndex].name = this.modal.form.name;
  460. this.hs.list[dbIndex].phone = this.modal.form.phone;
  461. } else {
  462. this.modal.form.index = this.hs.list.length;
  463. this.hs.list.push(this.modal.form);
  464. }
  465. this.modal.visible = false;
  466. this.handler();
  467. },
  468. editFn(data) {
  469. Object.assign(this.modal, {
  470. visible: true,
  471. form: data
  472. })
  473. },
  474. deleteFn(data) {
  475. this.hs.list.splice(data.index, 1);
  476. if (data.id) {
  477. this.$api.deleteHsPeople({
  478. id: data.id
  479. });
  480. }
  481. },
  482. getGoodsList() {
  483. this.$api.getGoodsList().then(resp => {
  484. this.goods.goodsList = resp.data;
  485. let goods = resp.data[0];
  486. let noNeedIds = goods.noNeedIds.split(',');
  487. this.needTypeId = goods.needIds.split(',')
  488. this.noNeedIds = goods.noNeedIds.split(',')
  489. this.$api.getItemList().then(resp => {
  490. let list = resp.data;
  491. this.itemList = list;
  492. this.filterItemList = list.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  493. this.checkStore();
  494. })
  495. })
  496. },
  497. handlerTypeItem(goods) {
  498. },
  499. idCardInput() {
  500. let val = this.form.driverIdCard;
  501. let list = this.driverList.filter(obj => obj.idCard.indexOf(val) !== -1);
  502. if (list.length > 0 && val) {
  503. this.driver.show = true;
  504. this.driver.filterList = list;
  505. } else {
  506. this.driver.show = false;
  507. }
  508. },
  509. selectDriverFn(item) {
  510. this.form.driverIdCard = item.idCard;
  511. this.form.driverName = item.name;
  512. this.form.driverPhone = item.phone
  513. let that = this;
  514. setTimeout(() => {
  515. that.driver.show = false;
  516. }, 150)
  517. },
  518. carInputFn() {
  519. this.handler();
  520. },
  521. selectCarNo(item) {
  522. this.form.cardNo = item.cardNo;
  523. this.form.cardSize = item.cardSize;
  524. this.form.netWeight = item.lastNetWeight;
  525. let names = this.goods.goodsList.map(obj => obj.name);
  526. let index = names.indexOf(item.lastGoodsName);
  527. this.goods.index = index == -1 ? 0 : index;
  528. this.country.index = this.country.list.indexOf(item.countryName)
  529. let that = this;
  530. this.handler();
  531. setTimeout(() => {
  532. this.car.carInput = false;
  533. }, 150)
  534. },
  535. getCustomerList() {
  536. this.$api.getCustomerList().then(resp => {
  537. this.customer.customerList = resp.data;
  538. })
  539. },
  540. selectItemFn(item) {
  541. let typeName = item.name;
  542. let checkItem = this.checkItem;
  543. if ((typeName == '干杂货人工装卸' && checkItem == '特殊车辆') ||
  544. (typeName == '特殊车辆' && checkItem == '干杂货人工装卸')) {
  545. this.$common.toast('不能同时选择干杂货人工装卸和特殊车辆');
  546. return false;
  547. }
  548. if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
  549. this.checkItem = typeName;
  550. }
  551. this.item = item;
  552. this.show = true;
  553. },
  554. cleanItemSelect(item) {
  555. item.itemName = '';
  556. setTimeout(() => {
  557. this.show = false;
  558. this.checkItem = ''
  559. }, 80)
  560. },
  561. itemSelectFn(data) {
  562. this.show = false;
  563. this.item.itemName = data;
  564. this.handler();
  565. },
  566. handler() {
  567. let goodsIndex = this.goods.index;
  568. let countryIndex = this.country.index;
  569. this.form.goodsName = this.goods.goodsList[goodsIndex].name;
  570. this.form.countryName = this.country.list[countryIndex];
  571. this.form.goodsIndex = goodsIndex;
  572. this.form.countryIndex = countryIndex;
  573. this.form.peopleJson = JSON.stringify(this.hs.list);
  574. this.form.carJson = JSON.stringify(this.china.list);
  575. let customerId = this.customerId;
  576. if (customerId == '1') {
  577. let customerIndex = this.customer.index;
  578. this.form.customerId = this.customer.customerList[customerIndex].id;
  579. this.form.customerIndex = customerIndex;
  580. }
  581. let inputItem = this.filterItemList.filter(obj => obj.itemName).map(o => {
  582. return {
  583. typeId: o.id,
  584. itemName: o.itemName,
  585. num: o.num
  586. }
  587. });
  588. this.form.inputItemJson = JSON.stringify(inputItem);
  589. let that = this;
  590. uni.setStorage({
  591. key: 'business_' + customerId,
  592. data: that.form
  593. })
  594. },
  595. checkStore() {
  596. let customerId = this.customerId;
  597. let data = uni.getStorageSync('business_' + customerId)
  598. if (data) {
  599. let that = this;
  600. uni.showModal({
  601. title: '提示',
  602. content: '您上次录入数据未提交,是否继续?',
  603. cancelText: '重新录入',
  604. confirmText: '继续',
  605. success(res) {
  606. if (res.confirm) {
  607. that.rebackStore(data);
  608. } else {
  609. uni.removeStorageSync('business_' + customerId)
  610. }
  611. }
  612. })
  613. }
  614. },
  615. rebackStore(data) {
  616. this.form = data;
  617. this.goods.index = data.goodsIndex ? data.goodsIndex : 0;
  618. this.customer.index = data.customerIndex ? data.customerIndex : 0;
  619. this.hs.list = data.peopleJson ? JSON.parse(data.peopleJson) : [];
  620. this.china.list = data.carJson ? JSON.parse(data.carJson) : [];
  621. if (data.inputItemJson) {
  622. let inputItemList = JSON.parse(data.inputItemJson);
  623. let filterList = this.filterItemList;
  624. for (let i in filterList) {
  625. let type = filterList[i];
  626. for (let j in inputItemList) {
  627. let s = inputItemList[j];
  628. if (type.id == s.typeId) {
  629. type.itemName = s.itemName;
  630. type.num = s.num;
  631. break;
  632. }
  633. }
  634. }
  635. }
  636. setTimeout(() => {
  637. this.car.carInput = false;
  638. }, 100)
  639. },
  640. check() {
  641. this.handler();
  642. if (!this.form.cardNo) {
  643. this.$common.toast('请录入境外车牌号')
  644. return false;
  645. }
  646. if (!this.$common.isNum(this.form.cardSize)) {
  647. this.$common.toast('车辆规格请录入数字')
  648. return false;
  649. }
  650. if (!this.form.netWeight || !this.$common.isNum(this.form.netWeight)) {
  651. this.$common.toast('载重必须输入数字')
  652. return false;
  653. }
  654. let typeList = this.filterItemList.filter(obj => obj.itemName);
  655. if (typeList.length == 0) {
  656. this.$common.toast('至少选择一项业务项')
  657. return false;
  658. }
  659. let noNeedIds = this.noNeedIds;
  660. let chechItem = this.checkItem;
  661. let filterItemList = this.filterItemList.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  662. for (let j in this.needTypeId) {
  663. let id = this.needTypeId[j];
  664. for (let i in filterItemList) {
  665. let type = filterItemList[i];
  666. let typeName = type.name;
  667. if (id == type.id && !type.itemName && typeName !== '特殊车辆' && typeName !== '干杂货人工装卸') {
  668. this.$common.toast('[' + type.name + ']必选')
  669. return;
  670. }
  671. }
  672. }
  673. if (!chechItem && this.form.goodsName == '干杂货') {
  674. this.$common.toast('请选择特殊车辆或干杂货人工装卸之一')
  675. return;
  676. }
  677. let peopleList = this.hs.list;
  678. if (typeList.filter(obj => obj.name.indexOf('人') !== -1 &&
  679. obj.name.indexOf('核酸') !== -1).length > 0 &&
  680. peopleList.length == 0) {
  681. this.$common.toast('录入核酸检测人员')
  682. return false;
  683. }
  684. let list = [];
  685. for (let i in typeList) {
  686. let type = typeList[i];
  687. type.num = 1;
  688. for (let j in type.items) {
  689. let item = type.items[j];
  690. if (type.itemName == item.itemName) {
  691. type.itemId = item.id;
  692. break;
  693. }
  694. }
  695. list.push({
  696. itemId: type.itemId,
  697. num: type.num
  698. })
  699. }
  700. this.form.itemJson = JSON.stringify(list);
  701. this.form.peopleJson = JSON.stringify(peopleList);
  702. this.form.carJson = JSON.stringify(this.china.list);
  703. this.form.items = null;
  704. if (this.customerId == '1') {
  705. this.form.customerId = this.customer.customerList[this.customer.index].id;
  706. } else {
  707. this.form.customerId = this.customerId;
  708. }
  709. this.form.goodsName = this.goods.goodsList[this.goods.index].name;
  710. return true;
  711. },
  712. saveFn() {
  713. if (this.check()) {
  714. let obj = this.$common.removeNull(this.form);
  715. this.$api.saveBusiness(obj).then(resp => {
  716. if (resp.code == 200) {
  717. uni.removeStorageSync('business_' + this.customerId);
  718. this.$common.toast('录入成功');
  719. this.hs.list = [];
  720. setTimeout(() => {
  721. this.$common.to('/pages/business-order/business-order')
  722. }, 1000)
  723. }
  724. })
  725. }
  726. },
  727. bindPickerChange(e) {
  728. var nowId = e.target.id; //当前picker的ID id需要自己设置 在picker中
  729. var value = e.detail.value; //当前picker选中的值
  730. switch (nowId) { //根据ID判断是哪个picker
  731. case "qy": //picker的ID
  732. this.customer.index = value;
  733. break;
  734. case "hw": //picker的ID
  735. this.goods.index = value;
  736. break;
  737. case "gj": //picker的ID
  738. this.country.index = value;
  739. break;
  740. }
  741. this.handler();
  742. },
  743. }
  744. }
  745. </script>
  746. <style lang="scss">
  747. page {
  748. background-color: #fff;
  749. }
  750. .hs-item {
  751. text-align: center;
  752. }
  753. .item-line {
  754. color: #a2a2a2;
  755. padding: 5px 0 10px 29px;
  756. border-bottom: 1px solid #E5E5E5;
  757. }
  758. .hj {
  759. padding: 50rpx;
  760. font-size: 40rpx;
  761. color: red;
  762. font-weight: bold;
  763. }
  764. .save-btn {
  765. background-color: #ff4200;
  766. height: 88rpx;
  767. display: flex;
  768. justify-content: center;
  769. align-items: center;
  770. margin: 60rpx;
  771. color: #fff;
  772. font-size: 30rpx;
  773. font-weight: bold;
  774. border-radius: 10rpx;
  775. }
  776. @import '@/common/common.scss'
  777. </style>