business-entering.vue 23 KB

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