business-edit.vue 17 KB

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