business-entering.vue 16 KB

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