business-entering.vue 17 KB

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