business-entering.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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="!hs.visible">
  35. <view class="top">
  36. <text class="title">业务录入</text>
  37. </view>
  38. <view class="item" v-show="customerId=='1'">
  39. <view class="l"><text style="color: red;">*</text>企业名称:</view>
  40. <view class="r">
  41. <picker v-if="customer.customerList.length>0" class="p-picker" id="qy"
  42. @change="bindPickerChange($event)" :value="customer.index" :range="customer.customerList"
  43. range-key="name">
  44. <text class="p-text">{{customer.customerList[customer.index].name}}</text>
  45. <u-icon class="p-icon" name="arrow-down-fill" size="20"></u-icon>
  46. </picker>
  47. </view>
  48. </view>
  49. <view class="item">
  50. <view class="l"><text style="color: red;">*</text>货物:</view>
  51. <view class="r">
  52. <picker v-if="goods.goodsList.length>0" class="p-picker" id="hw" @change="whChange($event)"
  53. :value="goods.index" :range="goods.goodsList" range-key="name">
  54. <text class="p-text">{{goods.goodsList[goods.index].name}}</text>
  55. <u-icon class="p-icon" name="arrow-down-fill" size="20"></u-icon>
  56. </picker>
  57. </view>
  58. </view>
  59. <view class="item">
  60. <view class="l"><text style="color: red;">*</text>载重:</view>
  61. <view class="r">
  62. <u-input type="number" placeholder="输入载重" @input="handler()" v-model="form.netWeight">
  63. <text slot="suffix">吨</text>
  64. </u-input>
  65. </view>
  66. </view>
  67. <view class="item">
  68. <view class="l"><text style="color: red;">*</text>境外车牌:</view>
  69. <view class="r">
  70. <u-input placeholder="输入车牌号" @input="handler()" v-model="form.cardNo" />
  71. </view>
  72. </view>
  73. <view class="item">
  74. <view class="l"><text style="color: red;">*</text>境外车规格:</view>
  75. <view class="r">
  76. <u-input type="number" placeholder="输入车辆规格" @blur="car.carInput=false" @input="carSizeInput"
  77. v-model="form.cardSize">
  78. <text slot="suffix">米</text>
  79. </u-input>
  80. </view>
  81. </view>
  82. <view class="item">
  83. <view class="l"><text style="color: red;">*</text>预计入场:</view>
  84. <view class="r">
  85. <view class="r">
  86. <uni-datetime-picker placeholder="请选择" @change="expectDayChange" :clear-icon="false"
  87. :start="exprctStart" type="datetime" v-model="form.expectInDay" @close="closeFn" />
  88. </view>
  89. </view>
  90. </view>
  91. <view class="item">
  92. <view class="l"><text style="color: red;">*</text>中国车牌号:</view>
  93. <view class="r">
  94. <u-input placeholder="中国车牌号" @input="handler()" v-model="form.chinaCarNo" />
  95. </view>
  96. </view>
  97. <view class="item">
  98. <view class="l"><text style="color: red;">*</text>中国司机:</view>
  99. <view class="r">
  100. <u-input placeholder="司机姓名" @input="handler()" v-model="form.driverName" />
  101. </view>
  102. </view>
  103. <view class="item">
  104. <view class="l"><text style="color: red;">*</text>联系号码:</view>
  105. <view class="r">
  106. <u-input placeholder="司机联系号码" @input="handler()" type="number" v-model="form.driverPhone" />
  107. </view>
  108. </view>
  109. <view class="item-line">
  110. 业务项
  111. </view>
  112. <view class="item" v-for="item in filterItemList" :key="item.id" v-if="item.items.length>0">
  113. <view class="l"><text v-if="needTypeId.indexOf(item.id)!==-1" style="color: red;">*</text>{{item.name}}:
  114. </view>
  115. <view class="r">
  116. <view @click="selectItemFn(item)">
  117. <u-input placeholder="请选择" v-model="item.itemName" readonly clearable style="width: 120px;">
  118. <u-icon name="close" v-if="item.itemName" slot="suffix" color="#E5E5E5;" size="5"
  119. @click="item.itemName=''"></u-icon>
  120. </u-input>
  121. </view>
  122. <u-input placeholder="数量" :disabled="item.inc==0" border="surround" v-model="item.num" type="number"
  123. style="width: 10px;" v-if="item.itemName"></u-input>
  124. <view style="margin-left: 20rpx;color: red;" v-if="item.itemName">
  125. {{item.items.filter(obj=>obj.itemName==item.itemName)[0].price*item.num}}元
  126. </view>
  127. <u-icon name="plus" style="position: absolute;right: 10rpx;"
  128. v-if="item.itemName&&item.name.indexOf('人')!==-1&&item.name.indexOf('核酸')!==-1"
  129. @click="addHsFn(item.itemName,item.num)"></u-icon>
  130. </view>
  131. </view>
  132. <view class="hj" v-show="totalPrice>0">
  133. 合计:{{totalPrice}}元
  134. </view>
  135. </view>
  136. <u-button type="primary" text="确定" @click="saveFn" v-show="!hs.visible"></u-button>
  137. <!-- ---------------------------------------------------------- -->
  138. <view class="bottom-safety"></view>
  139. <u-popup :show="car.carInput" :overlay="false" @close="car.carInput=false" borderRadius="10">
  140. <view style="padding: 40rpx;line-height: 60rpx;text-align: center;">
  141. <view v-for="item in filterUnitList" :id="item.id"
  142. style="margin-bottom: 20rpx;border-bottom: 1rpx solid #E5E5E5;" @click="selectCarSize(item)">
  143. {{item.unit}}
  144. </view>
  145. </view>
  146. </u-popup>
  147. <u-popup :show="driver.show" :overlay="false" @close="driver.show=false" borderRadius="10">
  148. <view style="padding: 40rpx;line-height: 60rpx;text-align: center;">
  149. <view v-for="item in driver.filterList" :id="item.id"
  150. style="margin-bottom: 20rpx;border-bottom: 1rpx solid #E5E5E5;" @click="selectDriverFn(item)">
  151. {{item.name}}({{item.idCard}})
  152. </view>
  153. </view>
  154. </u-popup>
  155. <u-popup :show="show" closeable closeOnClickOverlay @close="show=false">
  156. <view style="padding: 40rpx;">
  157. <u-radio-group @change="itemSelectFn" placement="column" v-model="item.itemName">
  158. <u-radio v-for="item in item.items" :key="item.id" :label="item.itemName" :name="item.itemName"
  159. v-if="form.netWeight >= item.minWeight
  160. && form.netWeight < item.maxWeight
  161. &&form.cardSize<=item.carLength
  162. &&form.cardSize>=item.minLength" style="margin-top: 30rpx;">
  163. </u-radio>
  164. </u-radio-group>
  165. </view>
  166. </u-popup>
  167. <u-modal :show="modal.visible" showCancelButton closeOnClickOverlay @cancel="modal.visible=false"
  168. @confirm="addHsPeopleFn">
  169. <view style="">
  170. <u--input placeholder="姓名" border="surround" v-model="modal.form.name"></u--input>
  171. <u--input style="margin-top: 20rpx;" placeholder="联系号码" border="surround" v-model="modal.form.phone">
  172. </u--input>
  173. </view>
  174. </u-modal>
  175. </view>
  176. </template>
  177. <script>
  178. export default {
  179. data() {
  180. return {
  181. car: {
  182. carInput: false,
  183. filterList: [],
  184. },
  185. driver: {
  186. show: false,
  187. filterList: [],
  188. },
  189. customerId: '1',
  190. exprctStart: new Date().getTime(),
  191. itemList: [],
  192. filterItemList: [],
  193. needTypeId: [],
  194. noNeedIds: [],
  195. form: {
  196. customerId: '',
  197. customerIndex: 0,
  198. countryIndex: 0,
  199. goodsIndex: 0,
  200. cardNo: '',
  201. cardSize: '',
  202. goodsName: '',
  203. netWeight: '',
  204. chinaCarNo: '',
  205. driverName: '',
  206. driverPhone: '',
  207. expectInDay: ''
  208. },
  209. show: false,
  210. item: {
  211. items: []
  212. },
  213. customer: {
  214. index: 0,
  215. customerList: [],
  216. },
  217. carList: [],
  218. driverList: [],
  219. unitList: [],
  220. filterUnitList: [],
  221. country: {
  222. index: 0,
  223. list: ['越南车', '中国车']
  224. },
  225. goods: {
  226. index: 0,
  227. goodsList: []
  228. },
  229. hs: {
  230. visible: false,
  231. num: 1,
  232. list: []
  233. },
  234. modal: {
  235. visible: false,
  236. form: {
  237. name: '',
  238. phone: ''
  239. }
  240. }
  241. }
  242. },
  243. onShow() {
  244. this.customerId = uni.getStorageSync('customerId');
  245. },
  246. computed: {
  247. totalPrice() {
  248. let itemList = this.itemList.filter(obj => obj.itemName);
  249. let price = 0;
  250. for (let i in itemList) {
  251. let type = itemList[i];
  252. let items = type.items;
  253. for (let j in items) {
  254. let item = items[j];
  255. if (item.itemName == type.itemName) {
  256. price += item.price;
  257. break;
  258. }
  259. }
  260. }
  261. return price;
  262. }
  263. },
  264. created() {
  265. if (this.customerId == '1') {
  266. this.getCustomerList();
  267. }
  268. this.getGoodsList();
  269. this.getUnit();
  270. },
  271. methods: {
  272. whChange(event) {
  273. let index = event.detail.value; //当前picker选中的值
  274. this.goods.index = index;
  275. let goods = this.goods.goodsList[index];
  276. let noNeedIds = goods.noNeedIds.split(',');
  277. this.needTypeId = goods.needIds.split(',');
  278. this.noNeedIds = goods.noNeedIds.split(',')
  279. this.filterItemList = this.itemList.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  280. this.handler();
  281. },
  282. carSizeInput() {
  283. let carSize = this.form.cardSize;
  284. let filterUnitList = this.unitList.filter(obj => obj.unit.indexOf(carSize) !== -1);
  285. this.car.carInput = filterUnitList.length > 0;
  286. this.filterUnitList = filterUnitList;
  287. this.handler();
  288. },
  289. getUnit() {
  290. this.$api.getUnitList().then(resp => {
  291. this.unitList = resp.data;
  292. })
  293. },
  294. selectCarSize(data) {
  295. this.form.cardSize = data.unit;
  296. this.car.carInput = false;
  297. this.handler();
  298. },
  299. expectDayChange(date) {
  300. this.form.expectInDay = date;
  301. this.handler();
  302. },
  303. addHsFn(itemName, num) {
  304. this.hs.visible = true;
  305. this.hs.num = num;
  306. },
  307. showHsModal() {
  308. Object.assign(this.modal, {
  309. visible: true,
  310. form: {
  311. name: '',
  312. phone: '',
  313. index: -1
  314. }
  315. });
  316. },
  317. addHsPeopleFn() {
  318. if (!this.modal.form.name) {
  319. this.$common.toast('请输入名称');
  320. return;
  321. }
  322. if (this.modal.form.phone && !this.$common.isPhone(this.modal.form.phone)) {
  323. this.$common.toast('联系号码不正确');
  324. return;
  325. }
  326. let dbIndex = this.modal.form.index;
  327. if (dbIndex >= 0) {
  328. this.hs.list[dbIndex].name = this.modal.form.name;
  329. this.hs.list[dbIndex].phone = this.modal.form.phone;
  330. } else {
  331. this.modal.form.index = this.hs.list.length;
  332. this.hs.list.push(this.modal.form);
  333. }
  334. this.modal.visible = false;
  335. this.handler();
  336. },
  337. editFn(data) {
  338. Object.assign(this.modal, {
  339. visible: true,
  340. form: data
  341. })
  342. },
  343. deleteFn(data) {
  344. this.hs.list.splice(data.index, 1);
  345. if (data.id) {
  346. this.$api.deleteHsPeople({
  347. id: data.id
  348. });
  349. }
  350. },
  351. getGoodsList() {
  352. this.$api.getGoodsList().then(resp => {
  353. this.goods.goodsList = resp.data;
  354. let goods = resp.data[0];
  355. let noNeedIds = goods.noNeedIds.split(',');
  356. this.needTypeId = goods.needIds.split(',')
  357. this.noNeedIds = goods.noNeedIds.split(',')
  358. this.$api.getItemList().then(resp => {
  359. let list = resp.data;
  360. this.itemList = list;
  361. this.filterItemList = list.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  362. this.checkStore();
  363. })
  364. })
  365. },
  366. handlerTypeItem(goods) {
  367. },
  368. idCardInput() {
  369. let val = this.form.driverIdCard;
  370. let list = this.driverList.filter(obj => obj.idCard.indexOf(val) !== -1);
  371. if (list.length > 0 && val) {
  372. this.driver.show = true;
  373. this.driver.filterList = list;
  374. } else {
  375. this.driver.show = false;
  376. }
  377. },
  378. selectDriverFn(item) {
  379. this.form.driverIdCard = item.idCard;
  380. this.form.driverName = item.name;
  381. this.form.driverPhone = item.phone
  382. let that = this;
  383. setTimeout(() => {
  384. that.driver.show = false;
  385. }, 150)
  386. },
  387. carInputFn() {
  388. this.handler();
  389. },
  390. selectCarNo(item) {
  391. this.form.cardNo = item.cardNo;
  392. this.form.cardSize = item.cardSize;
  393. this.form.netWeight = item.lastNetWeight;
  394. let names = this.goods.goodsList.map(obj => obj.name);
  395. let index = names.indexOf(item.lastGoodsName);
  396. this.goods.index = index == -1 ? 0 : index;
  397. this.country.index = this.country.list.indexOf(item.countryName)
  398. let that = this;
  399. this.handler();
  400. setTimeout(() => {
  401. this.car.carInput = false;
  402. }, 150)
  403. },
  404. getCustomerList() {
  405. this.$api.getCustomerList().then(resp => {
  406. this.customer.customerList = resp.data;
  407. })
  408. },
  409. selectItemFn(item) {
  410. this.item = item;
  411. this.show = true;
  412. },
  413. itemSelectFn(data) {
  414. this.show = false;
  415. this.item.itemName = data;
  416. this.handler();
  417. },
  418. handler() {
  419. let goodsIndex = this.goods.index;
  420. let countryIndex = this.country.index;
  421. this.form.goodsName = this.goods.goodsList[goodsIndex].name;
  422. this.form.countryName = this.country.list[countryIndex];
  423. this.form.goodsIndex = goodsIndex;
  424. this.form.countryIndex = countryIndex;
  425. this.form.peopleJson = JSON.stringify(this.hs.list);
  426. let customerId = this.customerId;
  427. if (customerId == '1') {
  428. let customerIndex = this.customer.index;
  429. this.form.customerId = this.customer.customerList[customerIndex].id;
  430. this.form.customerIndex = customerIndex;
  431. }
  432. let inputItem = this.filterItemList.filter(obj => obj.itemName).map(o => {
  433. return {
  434. typeId: o.id,
  435. itemName: o.itemName,
  436. num: o.num
  437. }
  438. });
  439. this.form.inputItemJson = JSON.stringify(inputItem);
  440. let that = this;
  441. uni.setStorage({
  442. key: 'business_' + customerId,
  443. data: that.form
  444. })
  445. },
  446. checkStore() {
  447. let customerId = this.customerId;
  448. let data = uni.getStorageSync('business_' + customerId)
  449. if (data) {
  450. let that = this;
  451. uni.showModal({
  452. title: '提示',
  453. content: '您上次录入数据未提交,是否继续?',
  454. cancelText: '重新录入',
  455. confirmText: '继续',
  456. success(res) {
  457. if (res.confirm) {
  458. that.rebackStore(data);
  459. } else {
  460. uni.removeStorageSync('business_' + customerId)
  461. }
  462. }
  463. })
  464. }
  465. },
  466. rebackStore(data) {
  467. this.form = data;
  468. this.goods.index = data.goodsIndex ? data.goodsIndex : 0;
  469. this.customer.index = data.customerIndex ? data.customerIndex : 0;
  470. this.hs.list = data.peopleJson ? JSON.parse(data.peopleJson) : [];
  471. if (data.inputItemJson) {
  472. let inputItemList = JSON.parse(data.inputItemJson);
  473. let filterList = this.filterItemList;
  474. for (let i in filterList) {
  475. let type = filterList[i];
  476. for (let j in inputItemList) {
  477. let s = inputItemList[j];
  478. if (type.id == s.typeId) {
  479. type.itemName = s.itemName;
  480. type.num = s.num;
  481. break;
  482. }
  483. }
  484. }
  485. }
  486. setTimeout(() => {
  487. this.car.carInput = false;
  488. }, 100)
  489. },
  490. check() {
  491. this.handler();
  492. if (!this.form.cardNo) {
  493. this.$common.toast('请录入境外车牌号')
  494. return false;
  495. }
  496. if (!this.$common.isNum(this.form.cardSize)) {
  497. this.$common.toast('车辆规格请录入数字')
  498. return false;
  499. }
  500. if (!this.form.chinaCarNo) {
  501. this.$common.toast('请录入中国车牌')
  502. return false;
  503. }
  504. if (!this.form.driverName) {
  505. this.$common.toast('请录入中国司机')
  506. return false;
  507. }
  508. if (!this.$common.isPhone(this.form.driverPhone)) {
  509. this.$common.toast('司机联系号码不正确')
  510. return false;
  511. }
  512. if (!this.form.netWeight || !this.$common.isNum(this.form.netWeight)) {
  513. this.$common.toast('载重必须输入数字')
  514. return false;
  515. }
  516. let typeList = this.filterItemList.filter(obj => obj.itemName);
  517. if (typeList.length == 0) {
  518. this.$common.toast('至少选择一项业务项')
  519. return false;
  520. }
  521. let noNeedIds = this.noNeedIds;
  522. let filterItemList = this.filterItemList.filter(obj => noNeedIds.indexOf(obj.id) == -1);
  523. for (let j in this.needTypeId) {
  524. let id = this.needTypeId[j];
  525. for (let i in filterItemList) {
  526. let type = filterItemList[i];
  527. if (id == type.id && !type.itemName) {
  528. this.$common.toast('[' + type.name + ']必选')
  529. return;
  530. }
  531. }
  532. }
  533. let peopleList = this.hs.list;
  534. if (typeList.filter(obj => obj.name.indexOf('人') !== -1 &&
  535. obj.name.indexOf('核酸') !== -1).length > 0 &&
  536. peopleList.length == 0) {
  537. this.$common.toast('录入核酸检测人员')
  538. return false;
  539. }
  540. let list = [];
  541. for (let i in typeList) {
  542. let type = typeList[i];
  543. type.num = 1;
  544. for (let j in type.items) {
  545. let item = type.items[j];
  546. if (type.itemName == item.itemName) {
  547. type.itemId = item.id;
  548. break;
  549. }
  550. }
  551. list.push({
  552. itemId: type.itemId,
  553. num: type.num
  554. })
  555. }
  556. this.form.itemJson = JSON.stringify(list);
  557. this.form.peopleJson = JSON.stringify(peopleList);
  558. this.form.items = null;
  559. if (this.customerId == '1') {
  560. this.form.customerId = this.customer.customerList[this.customer.index].id;
  561. } else {
  562. this.form.customerId = this.customerId;
  563. }
  564. this.form.goodsName = this.goods.goodsList[this.goods.index].name;
  565. return true;
  566. },
  567. saveFn() {
  568. if (this.check()) {
  569. let obj = this.$common.removeNull(this.form);
  570. this.$api.saveBusiness(obj).then(resp => {
  571. if (resp.code == 200) {
  572. uni.removeStorageSync('business_' + this.customerId);
  573. this.$common.toast('录入成功');
  574. this.hs.list = [];
  575. setTimeout(() => {
  576. this.$common.to('/pages/business-order/business-order')
  577. }, 1000)
  578. }
  579. })
  580. }
  581. },
  582. bindPickerChange(e) {
  583. var nowId = e.target.id; //当前picker的ID id需要自己设置 在picker中
  584. var value = e.detail.value; //当前picker选中的值
  585. switch (nowId) { //根据ID判断是哪个picker
  586. case "qy": //picker的ID
  587. this.customer.index = value;
  588. break;
  589. case "hw": //picker的ID
  590. this.goods.index = value;
  591. break;
  592. case "gj": //picker的ID
  593. this.country.index = value;
  594. break;
  595. }
  596. this.handler();
  597. },
  598. }
  599. }
  600. </script>
  601. <style lang="scss">
  602. page {
  603. background-color: #fff;
  604. }
  605. .hs-item {
  606. text-align: center;
  607. }
  608. .item-line {
  609. color: #a2a2a2;
  610. padding: 5px 0 10px 29px;
  611. border-bottom: 1px solid #E5E5E5;
  612. }
  613. .hj {
  614. padding: 50rpx;
  615. font-size: 40rpx;
  616. color: red;
  617. font-weight: bold;
  618. }
  619. .save-btn {
  620. background-color: #ff4200;
  621. height: 88rpx;
  622. display: flex;
  623. justify-content: center;
  624. align-items: center;
  625. margin: 60rpx;
  626. color: #fff;
  627. font-size: 30rpx;
  628. font-weight: bold;
  629. border-radius: 10rpx;
  630. }
  631. @import '@/common/common.scss'
  632. </style>