business-entering.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. if (this.form.id) {
  303. this.$api.getBusinessPeople({
  304. businessId: this.form.id
  305. }).then(resp => {
  306. let list = resp.data;
  307. let index = 0;
  308. let r = [];
  309. for (let i in list) {
  310. r.push({
  311. name: list[i].name,
  312. phone: list[i].phone,
  313. index: index,
  314. id: list[i].id
  315. })
  316. index++;
  317. }
  318. this.hs.list = r;
  319. })
  320. }
  321. },
  322. showHsModal() {
  323. Object.assign(this.modal, {
  324. visible: true,
  325. form: {
  326. name: '',
  327. phone: '',
  328. index: -1
  329. }
  330. });
  331. },
  332. addHsPeopleFn() {
  333. if (!this.modal.form.name) {
  334. this.$common.toast('请输入名称');
  335. return;
  336. }
  337. if (!this.modal.form.phone) {
  338. this.$common.toast('请输入联系号码');
  339. return;
  340. }
  341. let dbIndex = this.modal.form.index;
  342. if (dbIndex >= 0) {
  343. this.hs.list[dbIndex].name = this.modal.form.name;
  344. this.hs.list[dbIndex].phone = this.modal.form.phone;
  345. } else {
  346. this.modal.form.index = this.hs.list.length;
  347. this.hs.list.push(this.modal.form);
  348. }
  349. this.modal.visible = false;
  350. this.handler();
  351. },
  352. editFn(data) {
  353. Object.assign(this.modal, {
  354. visible: true,
  355. form: data
  356. })
  357. },
  358. deleteFn(data) {
  359. this.hs.list.splice(data.index, 1);
  360. if (data.id) {
  361. this.$api.deleteHsPeople({
  362. id: data.id
  363. });
  364. }
  365. },
  366. getGoodsList() {
  367. this.$api.getGoodsList().then(resp => {
  368. this.goods.goodsList = resp.data;
  369. })
  370. },
  371. getDriverList() {
  372. this.$api.getDriverList().then(resp => {
  373. this.driverList = resp.data;
  374. })
  375. },
  376. idCardInput() {
  377. let val = this.form.driverIdCard;
  378. let list = this.driverList.filter(obj => obj.idCard.indexOf(val) !== -1);
  379. if (list.length > 0 && val) {
  380. this.driver.show = true;
  381. this.driver.filterList = list;
  382. } else {
  383. this.driver.show = false;
  384. }
  385. },
  386. selectDriverFn(item) {
  387. this.form.driverIdCard = item.idCard;
  388. this.form.driverName = item.name;
  389. this.form.driverPhone = item.phone
  390. let that = this;
  391. setTimeout(() => {
  392. that.driver.show = false;
  393. }, 150)
  394. },
  395. getCarList() {
  396. this.$api.getCarList().then(resp => {
  397. this.carList = resp.data;
  398. })
  399. },
  400. carInputFn() {
  401. let val = this.form.cardNo;
  402. let list = this.carList.filter(obj => obj.cardNo.indexOf(val) !== -1);
  403. if (list.length > 0 && val) {
  404. this.car.carInput = true;
  405. this.car.filterList = list;
  406. } else {
  407. this.car.carInput = false;
  408. }
  409. this.handler();
  410. },
  411. selectCarNo(item) {
  412. this.form.cardNo = item.cardNo;
  413. this.form.cardSize = item.cardSize;
  414. this.form.netWeight = item.lastNetWeight;
  415. let names = this.goods.goodsList.map(obj => obj.name);
  416. let index = names.indexOf(item.lastGoodsName);
  417. this.goods.index = index == -1 ? 0 : index;
  418. this.country.index = this.country.list.indexOf(item.countryName)
  419. let that = this;
  420. this.handler();
  421. setTimeout(() => {
  422. this.car.carInput = false;
  423. }, 150)
  424. },
  425. getCustomerList() {
  426. this.$api.getCustomerList().then(resp => {
  427. this.customer.customerList = resp.data;
  428. })
  429. },
  430. getItemList() {
  431. this.$api.getItemList().then(resp => {
  432. this.itemList = resp.data;
  433. })
  434. },
  435. selectItemFn(item) {
  436. this.item = item;
  437. this.show = true;
  438. },
  439. itemSelectFn(data) {
  440. this.show = false;
  441. this.item.itemName = data;
  442. this.handler();
  443. },
  444. handler() {
  445. let goodsIndex = this.goods.index;
  446. let countryIndex = this.country.index;
  447. this.form.goodsName = this.goods.goodsList[goodsIndex].name;
  448. this.form.countryName = this.country.list[countryIndex];
  449. this.form.goodsIndex = goodsIndex;
  450. this.form.countryIndex = countryIndex;
  451. this.form.peopleJson = JSON.stringify(this.hs.list);
  452. let customerId = this.customerId;
  453. if (customerId == '1') {
  454. let customerIndex = this.customer.index;
  455. this.form.customerId = this.customer.customerList[customerIndex].id;
  456. this.form.customerIndex = customerIndex;
  457. }
  458. let that = this;
  459. uni.setStorage({
  460. key: 'business_' + customerId,
  461. data: that.form
  462. })
  463. },
  464. checkStore() {
  465. let customerId = this.customerId;
  466. let data = uni.getStorageSync('business_' + customerId)
  467. if (data) {
  468. let that = this;
  469. uni.showModal({
  470. title: '提示',
  471. content: '您上次录入数据未提交,是否继续?',
  472. cancelText: '重新录入',
  473. confirmText: '继续',
  474. success(res) {
  475. if (res.confirm) {
  476. that.rebackStore(data);
  477. } else {
  478. uni.removeStorageSync('business_' + customerId)
  479. }
  480. }
  481. })
  482. }
  483. },
  484. rebackStore(data) {
  485. this.form = data;
  486. this.goods.index = data.goodsIndex ? data.goodsIndex : 0;
  487. this.customer.index = data.customerIndex ? data.customerIndex : 0;
  488. this.country.index = data.countryIndex ? data.countryIndex : 0;
  489. this.hs.list = data.peopleJson ? JSON.parse(data.peopleJson) : []
  490. setTimeout(() => {
  491. this.car.carInput = false;
  492. this.driver.show = false;
  493. }, 150)
  494. },
  495. check() {
  496. this.handler();
  497. if (!this.form.cardNo) {
  498. this.$common.toast('请录入境外车牌号')
  499. return false;
  500. }
  501. if (!this.form.cardSize) {
  502. this.$common.toast('请录入车辆规格')
  503. return false;
  504. }
  505. if (!this.form.chinaCarNo) {
  506. this.$common.toast('请录入中国车牌')
  507. return false;
  508. }
  509. if (!this.form.driverName) {
  510. this.$common.toast('请录入中国司机')
  511. return false;
  512. }
  513. if (!this.form.driverPhone) {
  514. this.$common.toast('请录入司机联系号码')
  515. return false;
  516. }
  517. let typeList = this.itemList.filter(obj => obj.itemName);
  518. if (typeList.length == 0) {
  519. this.$common.toast('至少选择一项业务项')
  520. return false;
  521. }
  522. if (typeList.filter(obj => obj.name.indexOf('核酸') !== -1).length > 0 && this.hs.list.length == 0) {
  523. this.$common.toast('录入核酸检测人员')
  524. return false;
  525. }
  526. let list = [];
  527. for (let i in typeList) {
  528. let type = typeList[i];
  529. type.num = 1;
  530. for (let j in type.items) {
  531. let item = type.items[j];
  532. if (type.itemName == item.itemName) {
  533. type.itemId = item.id;
  534. break;
  535. }
  536. }
  537. list.push({
  538. itemId: type.itemId,
  539. num: type.num
  540. })
  541. }
  542. this.form.itemJson = JSON.stringify(list);
  543. this.form.items = null;
  544. if (this.customerId == '1') {
  545. this.form.customerId = this.customer.customerList[this.customer.index].id;
  546. } else {
  547. this.form.customerId = this.customerId;
  548. }
  549. return true;
  550. },
  551. saveFn() {
  552. if (this.check()) {
  553. let obj = this.$common.removeNull(this.form);
  554. this.$api.saveBusiness(obj).then(resp => {
  555. if (resp.code == 200) {
  556. uni.removeStorageSync('business_' + this.customerId);
  557. this.$common.toast('录入成功');
  558. this.hs.list = [];
  559. setTimeout(() => {
  560. this.$common.to('/pages/business-order/business-order')
  561. }, 1000)
  562. }
  563. })
  564. }
  565. },
  566. bindPickerChange(e) {
  567. var nowId = e.target.id; //当前picker的ID id需要自己设置 在picker中
  568. var value = e.detail.value; //当前picker选中的值
  569. switch (nowId) { //根据ID判断是哪个picker
  570. case "qy": //picker的ID
  571. this.customer.index = value;
  572. break;
  573. case "hw": //picker的ID
  574. this.goods.index = value;
  575. break;
  576. case "gj": //picker的ID
  577. this.country.index = value;
  578. break;
  579. }
  580. this.handler();
  581. },
  582. }
  583. }
  584. </script>
  585. <style lang="scss">
  586. page {
  587. background-color: #fff;
  588. }
  589. .hs-item {
  590. text-align: center;
  591. }
  592. .item-line {
  593. color: #a2a2a2;
  594. padding: 5px 0 10px 29px;
  595. border-bottom: 1px solid #E5E5E5;
  596. }
  597. .hj {
  598. padding: 50rpx;
  599. font-size: 40rpx;
  600. color: red;
  601. font-weight: bold;
  602. }
  603. .save-btn {
  604. background-color: #ff4200;
  605. height: 88rpx;
  606. display: flex;
  607. justify-content: center;
  608. align-items: center;
  609. margin: 60rpx;
  610. color: #fff;
  611. font-size: 30rpx;
  612. font-weight: bold;
  613. border-radius: 10rpx;
  614. }
  615. @import '@/common/common.scss'
  616. </style>