business-entering.vue 16 KB

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