business-entering.vue 18 KB

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