business-entering.vue 16 KB

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