business-entering.vue 16 KB

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