business-entering.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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)&&perList.indexOf('tb-business-add')!==-1"></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. perList:[]
  302. }
  303. },
  304. onShow() {
  305. this.customerId = uni.getStorageSync('customerId');
  306. this.perList=uni.getStorageSync('perList')
  307. },
  308. computed: {
  309. totalPrice() {
  310. let itemList = this.itemList.filter(obj => obj.itemName);
  311. let price = 0;
  312. for (let i in itemList) {
  313. let type = itemList[i];
  314. let items = type.items;
  315. for (let j in items) {
  316. let item = items[j];
  317. if (item.itemName == type.itemName) {
  318. price += item.price;
  319. break;
  320. }
  321. }
  322. }
  323. return price;
  324. },
  325. },
  326. created() {
  327. if (this.customerId == '1') {
  328. this.getCustomerList();
  329. }
  330. this.getGoodsList();
  331. this.getUnit();
  332. },
  333. onLoad(options) {
  334. let that = this;
  335. uni.$on('getSelectDeclare', declare => {
  336. that.$nextTick(() => {
  337. that.form.declareNo = declare.declareNo;
  338. that.form.cardNo = declare.carNo;
  339. that.form.chinaCarNo = declare.chinaCarNo;
  340. that.form.netWeight = declare.grossWeight;
  341. let chinaCarNo = declare.chinaCarNo;
  342. if (chinaCarNo) {
  343. let list = [];
  344. chinaCarNo.replace(",", ",").split(",").forEach(carNo => {
  345. let obj = {
  346. carNo: carNo
  347. }
  348. list.push(obj);
  349. that.china.list = list;
  350. })
  351. }else{
  352. that.china.list =[];
  353. }
  354. })
  355. })
  356. },
  357. methods: {
  358. selectDeclare() {
  359. this.$common.to('/pages/business-entering/declare-select?declareNo=' + this.form.declareNo)
  360. },
  361. addCar() {
  362. this.china.visible = true;
  363. },
  364. showChinaModal() {
  365. Object.assign(this.chinaAddModal, {
  366. visible: true,
  367. index: -1,
  368. form: {
  369. carNo: '',
  370. driverName: '',
  371. driverPhone: ''
  372. }
  373. })
  374. },
  375. sureCarFn() {
  376. let form = this.chinaAddModal.form;
  377. let carNo = form.carNo;
  378. let phone = form.driverPhone;
  379. if (carNo && !this.$common.isCarNo(carNo)) {
  380. this.$common.toast('请输入正确的车牌号')
  381. return;
  382. }
  383. if (phone && !this.$common.isPhone(phone)) {
  384. this.$common.toast('请输入正确的手机号')
  385. return;
  386. }
  387. let list = this.china.list;
  388. let index = this.chinaAddModal.index;
  389. if (index > -1) {
  390. list.splice(index, 1)
  391. }
  392. list.push(form)
  393. this.chinaAddModal.visible = false;
  394. },
  395. deleteChinaCar(item, index) {
  396. this.china.list.splice(index, 1);
  397. },
  398. editChinaCar(item, index) {
  399. Object.assign(this.chinaAddModal, {
  400. visible: true,
  401. index: index,
  402. form: item
  403. })
  404. },
  405. whChange(event) {
  406. let index = event.detail.value; //当前picker选中的值
  407. this.goods.index = index;
  408. let goods = this.goods.goodsList[index];
  409. let noNeedIds = goods.noNeedIds.split(',');
  410. this.needTypeId = goods.needIds.split(',');
  411. this.noNeedIds = goods.noNeedIds.split(',')
  412. this.filterItemList = this.itemList.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  413. this.handler();
  414. },
  415. carSizeInput() {
  416. let carSize = this.form.cardSize;
  417. let filterUnitList = this.unitList.filter(obj => obj.unit.indexOf(carSize) !== -1);
  418. this.car.carInput = filterUnitList.length > 0;
  419. this.filterUnitList = filterUnitList;
  420. this.handler();
  421. },
  422. getUnit() {
  423. this.$api.getUnitList().then(resp => {
  424. this.unitList = resp.data;
  425. })
  426. },
  427. selectCarSize(data) {
  428. this.form.cardSize = data.unit;
  429. this.car.carInput = false;
  430. this.handler();
  431. },
  432. expectDayChange(date) {
  433. this.form.expectInDay = date;
  434. this.handler();
  435. },
  436. addHsFn(itemName, num) {
  437. this.hs.visible = true;
  438. this.hs.num = num;
  439. },
  440. showHsModal() {
  441. Object.assign(this.modal, {
  442. visible: true,
  443. form: {
  444. name: '',
  445. phone: '',
  446. index: -1
  447. }
  448. });
  449. },
  450. addHsPeopleFn() {
  451. if (!this.modal.form.name) {
  452. this.$common.toast('请输入名称');
  453. return;
  454. }
  455. if (this.modal.form.phone && !this.$common.isPhone(this.modal.form.phone)) {
  456. this.$common.toast('联系号码不正确');
  457. return;
  458. }
  459. let dbIndex = this.modal.form.index;
  460. if (dbIndex >= 0) {
  461. this.hs.list[dbIndex].name = this.modal.form.name;
  462. this.hs.list[dbIndex].phone = this.modal.form.phone;
  463. } else {
  464. this.modal.form.index = this.hs.list.length;
  465. this.hs.list.push(this.modal.form);
  466. }
  467. this.modal.visible = false;
  468. this.handler();
  469. },
  470. editFn(data) {
  471. Object.assign(this.modal, {
  472. visible: true,
  473. form: data
  474. })
  475. },
  476. deleteFn(data) {
  477. this.hs.list.splice(data.index, 1);
  478. if (data.id) {
  479. this.$api.deleteHsPeople({
  480. id: data.id
  481. });
  482. }
  483. },
  484. getGoodsList() {
  485. this.$api.getGoodsList().then(resp => {
  486. this.goods.goodsList = resp.data;
  487. let goods = resp.data[0];
  488. let noNeedIds = goods.noNeedIds.split(',');
  489. this.needTypeId = goods.needIds.split(',')
  490. this.noNeedIds = goods.noNeedIds.split(',')
  491. this.$api.getItemList({business:1}).then(resp => {
  492. let list = resp.data;
  493. this.itemList = list;
  494. this.filterItemList = list.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  495. this.checkStore();
  496. })
  497. })
  498. },
  499. handlerTypeItem(goods) {
  500. },
  501. idCardInput() {
  502. let val = this.form.driverIdCard;
  503. let list = this.driverList.filter(obj => obj.idCard.indexOf(val) !== -1);
  504. if (list.length > 0 && val) {
  505. this.driver.show = true;
  506. this.driver.filterList = list;
  507. } else {
  508. this.driver.show = false;
  509. }
  510. },
  511. selectDriverFn(item) {
  512. this.form.driverIdCard = item.idCard;
  513. this.form.driverName = item.name;
  514. this.form.driverPhone = item.phone
  515. let that = this;
  516. setTimeout(() => {
  517. that.driver.show = false;
  518. }, 150)
  519. },
  520. carInputFn() {
  521. this.handler();
  522. },
  523. selectCarNo(item) {
  524. this.form.cardNo = item.cardNo;
  525. this.form.cardSize = item.cardSize;
  526. this.form.netWeight = item.lastNetWeight;
  527. let names = this.goods.goodsList.map(obj => obj.name);
  528. let index = names.indexOf(item.lastGoodsName);
  529. this.goods.index = index == -1 ? 0 : index;
  530. this.country.index = this.country.list.indexOf(item.countryName)
  531. let that = this;
  532. this.handler();
  533. setTimeout(() => {
  534. this.car.carInput = false;
  535. }, 150)
  536. },
  537. getCustomerList() {
  538. this.$api.getCustomerList({type:0}).then(resp => {
  539. this.customer.customerList = resp.data;
  540. })
  541. },
  542. selectItemFn(item) {
  543. let typeName = item.name;
  544. let checkItem = this.checkItem;
  545. if ((typeName == '干杂货人工装卸' && checkItem == '特殊车辆') ||
  546. (typeName == '特殊车辆' && checkItem == '干杂货人工装卸')) {
  547. this.$common.toast('不能同时选择干杂货人工装卸和特殊车辆');
  548. return false;
  549. }
  550. if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
  551. this.checkItem = typeName;
  552. }
  553. this.item = item;
  554. this.show = true;
  555. },
  556. cleanItemSelect(item) {
  557. item.itemName = '';
  558. setTimeout(() => {
  559. this.show = false;
  560. this.checkItem = ''
  561. }, 80)
  562. },
  563. itemSelectFn(data) {
  564. this.show = false;
  565. this.item.itemName = data;
  566. this.handler();
  567. },
  568. handler() {
  569. let goodsIndex = this.goods.index;
  570. let countryIndex = this.country.index;
  571. this.form.goodsName = this.goods.goodsList[goodsIndex].name;
  572. this.form.countryName = this.country.list[countryIndex];
  573. this.form.goodsIndex = goodsIndex;
  574. this.form.countryIndex = countryIndex;
  575. this.form.peopleJson = JSON.stringify(this.hs.list);
  576. this.form.carJson = JSON.stringify(this.china.list);
  577. let customerId = this.customerId;
  578. if (customerId == '1') {
  579. let customerIndex = this.customer.index;
  580. this.form.customerId = this.customer.customerList[customerIndex].id;
  581. this.form.customerIndex = customerIndex;
  582. }
  583. let inputItem = this.filterItemList.filter(obj => obj.itemName).map(o => {
  584. return {
  585. typeId: o.id,
  586. itemName: o.itemName,
  587. num: o.num
  588. }
  589. });
  590. this.form.inputItemJson = JSON.stringify(inputItem);
  591. let that = this;
  592. uni.setStorage({
  593. key: 'business_' + customerId,
  594. data: that.form
  595. })
  596. },
  597. checkStore() {
  598. let customerId = this.customerId;
  599. let data = uni.getStorageSync('business_' + customerId)
  600. if (data) {
  601. let that = this;
  602. uni.showModal({
  603. title: '提示',
  604. content: '您上次录入数据未提交,是否继续?',
  605. cancelText: '重新录入',
  606. confirmText: '继续',
  607. success(res) {
  608. if (res.confirm) {
  609. that.rebackStore(data);
  610. } else {
  611. uni.removeStorageSync('business_' + customerId)
  612. }
  613. }
  614. })
  615. }
  616. },
  617. rebackStore(data) {
  618. this.form = data;
  619. this.goods.index = data.goodsIndex ? data.goodsIndex : 0;
  620. this.customer.index = data.customerIndex ? data.customerIndex : 0;
  621. this.hs.list = data.peopleJson ? JSON.parse(data.peopleJson) : [];
  622. this.china.list = data.carJson ? JSON.parse(data.carJson) : [];
  623. if (data.inputItemJson) {
  624. let inputItemList = JSON.parse(data.inputItemJson);
  625. let filterList = this.filterItemList;
  626. for (let i in filterList) {
  627. let type = filterList[i];
  628. for (let j in inputItemList) {
  629. let s = inputItemList[j];
  630. if (type.id == s.typeId) {
  631. type.itemName = s.itemName;
  632. type.num = s.num;
  633. break;
  634. }
  635. }
  636. }
  637. }
  638. setTimeout(() => {
  639. this.car.carInput = false;
  640. }, 100)
  641. },
  642. check() {
  643. this.handler();
  644. if (!this.form.cardNo) {
  645. this.$common.toast('请录入境外车牌号')
  646. return false;
  647. }
  648. if (!this.$common.isNum(this.form.cardSize)) {
  649. this.$common.toast('车辆规格请录入数字')
  650. return false;
  651. }
  652. if (!this.form.netWeight || !this.$common.isNum(this.form.netWeight)) {
  653. this.$common.toast('载重必须输入数字')
  654. return false;
  655. }
  656. let typeList = this.filterItemList.filter(obj => obj.itemName);
  657. if (typeList.length == 0) {
  658. this.$common.toast('至少选择一项业务项')
  659. return false;
  660. }
  661. let noNeedIds = this.noNeedIds;
  662. let chechItem = this.checkItem;
  663. let filterItemList = this.filterItemList.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  664. for (let j in this.needTypeId) {
  665. let id = this.needTypeId[j];
  666. for (let i in filterItemList) {
  667. let type = filterItemList[i];
  668. let typeName = type.name;
  669. if (id == type.id && !type.itemName && typeName !== '特殊车辆' && typeName !== '干杂货人工装卸') {
  670. this.$common.toast('[' + type.name + ']必选')
  671. return;
  672. }
  673. }
  674. }
  675. if (!chechItem && this.form.goodsName == '干杂货') {
  676. this.$common.toast('请选择特殊车辆或干杂货人工装卸之一')
  677. return;
  678. }
  679. let peopleList = this.hs.list;
  680. if (typeList.filter(obj => obj.name.indexOf('人') !== -1 &&
  681. obj.name.indexOf('核酸') !== -1).length > 0 &&
  682. peopleList.length == 0) {
  683. this.$common.toast('录入核酸检测人员')
  684. return false;
  685. }
  686. let list = [];
  687. for (let i in typeList) {
  688. let type = typeList[i];
  689. type.num = 1;
  690. for (let j in type.items) {
  691. let item = type.items[j];
  692. if (type.itemName == item.itemName) {
  693. type.itemId = item.id;
  694. break;
  695. }
  696. }
  697. list.push({
  698. itemId: type.itemId,
  699. num: type.num
  700. })
  701. }
  702. this.form.itemJson = JSON.stringify(list);
  703. this.form.peopleJson = JSON.stringify(peopleList);
  704. this.form.carJson = JSON.stringify(this.china.list);
  705. this.form.items = null;
  706. if (this.customerId == '1') {
  707. this.form.customerId = this.customer.customerList[this.customer.index].id;
  708. } else {
  709. this.form.customerId = this.customerId;
  710. }
  711. this.form.goodsName = this.goods.goodsList[this.goods.index].name;
  712. return true;
  713. },
  714. saveFn() {
  715. if (this.check()) {
  716. let obj = this.$common.removeNull(this.form);
  717. this.$api.saveBusiness(obj).then(resp => {
  718. if (resp.code == 200) {
  719. uni.removeStorageSync('business_' + this.customerId);
  720. this.$common.toast('录入成功');
  721. this.hs.list = [];
  722. setTimeout(() => {
  723. this.$common.to('/pages/business-order/business-order')
  724. }, 1000)
  725. }
  726. })
  727. }
  728. },
  729. bindPickerChange(e) {
  730. var nowId = e.target.id; //当前picker的ID id需要自己设置 在picker中
  731. var value = e.detail.value; //当前picker选中的值
  732. switch (nowId) { //根据ID判断是哪个picker
  733. case "qy": //picker的ID
  734. this.customer.index = value;
  735. break;
  736. case "hw": //picker的ID
  737. this.goods.index = value;
  738. break;
  739. case "gj": //picker的ID
  740. this.country.index = value;
  741. break;
  742. }
  743. this.handler();
  744. },
  745. }
  746. }
  747. </script>
  748. <style lang="scss">
  749. page {
  750. background-color: #fff;
  751. }
  752. .hs-item {
  753. text-align: center;
  754. }
  755. .item-line {
  756. color: #a2a2a2;
  757. padding: 5px 0 10px 29px;
  758. border-bottom: 1px solid #E5E5E5;
  759. }
  760. .hj {
  761. padding: 50rpx;
  762. font-size: 40rpx;
  763. color: red;
  764. font-weight: bold;
  765. }
  766. .save-btn {
  767. background-color: #ff4200;
  768. height: 88rpx;
  769. display: flex;
  770. justify-content: center;
  771. align-items: center;
  772. margin: 60rpx;
  773. color: #fff;
  774. font-size: 30rpx;
  775. font-weight: bold;
  776. border-radius: 10rpx;
  777. }
  778. @import '@/common/common.scss'
  779. </style>