123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614 |
- <template>
- <view>
- <view class="box" v-show="hs.visible">
- <view class="top">
- <text class="title">录入核酸人员</text>
- </view>
- <view style="display: flex;">
- <u-button type="primary" @click="hs.visible=false" text="返回" style="width: 20px;" size="mini" />
- <u-button type="primary" @click="showHsModal" text="添加" icon="plus" style="width: 20px;" size="mini" />
- </view>
- <u-row style="margin-top: 70rpx;">
- <u-col span="4" style="text-align: center;">姓名</u-col>
- <u-col span="4" style="text-align: center;">联系号码</u-col>
- <u-col span="4" style="text-align: center;">操作</u-col>
- </u-row>
- <u-row v-for="item in hs.list" style="margin-top: 40rpx;">
- <u-col span="4" style="text-align: center;">{{item.name}}</u-col>
- <u-col span="4" style="text-align: center;">{{item.phone}}</u-col>
- <u-col span="4" style="text-align: center;">
- <u-row>
- <u-col span="6">
- <u-button type="primary" text="编辑" style="width: 20px;" @click="editFn(item)" size="mini">
- </u-button>
- </u-col>
- <u-col span="6">
- <u-button type="error" style="width: 20px;" text="删除" @click="deleteFn(item)" size="mini">
- </u-button>
- </u-col>
- </u-row>
- </u-col>
- </u-row>
- </view>
- <view class="box" v-show="!hs.visible">
- <view class="top">
- <text class="title">业务录入</text>
- </view>
- <view class="item" v-show="customerId=='1'">
- <view class="l">企业名称:</view>
- <view class="r">
- <picker v-if="customer.customerList.length>0" class="p-picker" id="qy"
- @change="bindPickerChange($event)" :value="customer.index" :range="customer.customerList"
- range-key="name">
- <text class="p-text">{{customer.customerList[customer.index].name}}</text>
- <u-icon class="p-icon" name="arrow-down-fill" size="20"></u-icon>
- </picker>
- </view>
- </view>
- <view class="item">
- <view class="l">境外车牌:</view>
- <view class="r">
- <u-input placeholder="输入车牌号" @input="carInputFn" v-model="form.cardNo" />
- </view>
- </view>
- <view class="item">
- <view class="l">规格(米):</view>
- <view class="r">
- <u-input type="number" placeholder="输入车辆规格" v-model="form.cardSize" />
- </view>
- </view>
- <view class="item">
- <view class="l">载重(吨):</view>
- <view class="r">
- <u-input type="number" placeholder="输入载重" v-model="form.netWeight" />
- </view>
- </view>
- <view class="item">
- <view class="l">货物:</view>
- <view class="r">
- <picker v-if="goods.goodsList.length>0" class="p-picker" id="hw" @change="bindPickerChange($event)"
- :value="goods.index" :range="goods.goodsList" range-key="name">
- <text class="p-text">{{goods.goodsList[goods.index].name}}</text>
- <u-icon class="p-icon" name="arrow-down-fill" size="20"></u-icon>
- </picker>
- </view>
- </view>
- <view class="item">
- <view class="l">预计入场:</view>
- <view class="r">
- <view class="r">
- <uni-datetime-picker placeholder="请选择" type="datetime" v-model="form.expectInDay"
- @close="closeFn" />
- </view>
- </view>
- </view>
- <view class="item">
- <view class="l">中国车牌号:</view>
- <view class="r">
- <u-input placeholder="中国车牌号" @input="handler()" v-model="form.chinaCarNo" />
- </view>
- </view>
- <view class="item">
- <view class="l">中国司机:</view>
- <view class="r">
- <u-input placeholder="司机姓名" @input="handler()" v-model="form.driverName" />
- </view>
- </view>
- <view class="item">
- <view class="l">联系号码:</view>
- <view class="r">
- <u-input placeholder="司机联系号码" @input="handler()" v-model="form.driverPhone" />
- </view>
- </view>
- <view class="item-line">
- 业务项
- </view>
- <view class="item" v-for="item in itemList" :key="item.id" v-if="item.items.length>0">
- <view class="l">{{item.name}}:</view>
- <view class="r">
- <view @click="selectItemFn(item)">
- <u-input placeholder="请选择" v-model="item.itemName" readonly clearable style="width: 120px;">
- <u-icon name="close" v-if="item.itemName" slot="suffix" color="#E5E5E5;" size="5"
- @click="item.itemName=''"></u-icon>
- </u-input>
- </view>
- <u-input placeholder="数量" border="surround" v-model="item.num" type="number" style="width: 10px;"
- v-if="item.itemName"></u-input>
- <view style="margin-left: 20rpx;color: red;" v-if="item.itemName">
- {{item.items.filter(obj=>obj.itemName==item.itemName)[0].price*item.num}}元
- </view>
- <u-icon name="plus" style="position: absolute;right: 10rpx;"
- v-if="item.itemName&&item.name.indexOf('人员核酸检测')!==-1" @click="addHsFn(item.itemName)"></u-icon>
- </view>
- </view>
- <view class="hj" v-show="totalPrice>0">
- 合计:{{totalPrice}}元
- </view>
- </view>
- <u-button type="primary" text="确定" @click="saveFn" v-show="!hs.visible"></u-button>
- <!-- ---------------------------------------------------------- -->
- <view class="bottom-safety"></view>
- <u-popup :show="car.carInput" :overlay="false" @close="car.carInput=false" borderRadius="10">
- <view style="padding: 40rpx;line-height: 60rpx;text-align: center;">
- <view v-for="item in car.filterList" :id="item.id"
- style="margin-bottom: 20rpx;border-bottom: 1rpx solid #E5E5E5;" @click="selectCarNo(item)">
- {{item.cardNo}}({{item.cardSize}})
- </view>
- </view>
- </u-popup>
- <u-popup :show="driver.show" :overlay="false" @close="driver.show=false" borderRadius="10">
- <view style="padding: 40rpx;line-height: 60rpx;text-align: center;">
- <view v-for="item in driver.filterList" :id="item.id"
- style="margin-bottom: 20rpx;border-bottom: 1rpx solid #E5E5E5;" @click="selectDriverFn(item)">
- {{item.name}}({{item.idCard}})
- </view>
- </view>
- </u-popup>
- <u-popup :show="show" closeable closeOnClickOverlay @close="show=false">
- <view style="padding: 40rpx;">
- <u-radio-group @change="itemSelectFn" placement="column" v-model="item.itemName">
- <u-radio v-for="item in item.items" :key="item.id" :label="item.itemName" :name="item.itemName"
- style="margin-top: 30rpx;">
- </u-radio>
- </u-radio-group>
- </view>
- </u-popup>
- <u-modal :show="modal.visible" showCancelButton closeOnClickOverlay @cancel="modal.visible=false"
- @confirm="addHsPeopleFn">
- <view style="">
- <u--input placeholder="姓名" border="surround" v-model="modal.form.name"></u--input>
- <u--input style="margin-top: 20rpx;" placeholder="联系号码" border="surround" v-model="modal.form.phone">
- </u--input>
- </view>
- </u-modal>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- car: {
- carInput: false,
- filterList: [],
- },
- driver: {
- show: false,
- filterList: [],
- },
- customerId: '1',
- itemList: [],
- form: {
- customerId: '',
- customerIndex: 0,
- countryIndex: 0,
- goodsIndex: 0,
- cardNo: '',
- cardSize: '',
- goodsName: '',
- netWeight: '',
- chinaCarNo: '',
- driverName: '',
- driverPhone: ''
- },
- show: false,
- item: {
- items: []
- },
- customer: {
- index: 0,
- customerList: [],
- },
- carList: [],
- driverList: [],
- country: {
- index: 0,
- list: ['越南车', '中国车']
- },
- goods: {
- index: 0,
- goodsList: []
- },
- hs: {
- visible: false,
- list: []
- },
- modal: {
- visible: false,
- form: {
- name: '',
- phone: ''
- }
- }
- }
- },
- onLoad(optsions) {
- this.form.id = optsions.id;
- },
- onShow() {
- this.customerId = uni.getStorageSync('customerId');
- if (!this.form.id) {
- setTimeout(() => {
- this.checkStore();
- }, 1000)
- }
- },
- computed: {
- totalPrice() {
- let itemList = this.itemList.filter(obj => obj.itemName);
- let price = 0;
- for (let i in itemList) {
- let type = itemList[i];
- let items = type.items;
- for (let j in items) {
- let item = items[j];
- if (item.itemName == type.itemName) {
- price += item.price;
- break;
- }
- }
- }
- return price;
- }
- },
- created() {
- this.getItemList();
- if (this.customerId == '1') {
- this.getCustomerList();
- }
- this.getCarList();
- this.getDriverList();
- this.getGoodsList();
- if (this.form.id) {
- this.$common.showLoading('加载中...')
- setTimeout(() => {
- this.getBusinessById();
- }, 800)
- }
- },
- methods: {
- closeFn(data) {
- console.log(data);
- },
- getBusinessById() {
- this.$api.getBusinessById({
- id: this.form.id
- }).then(resp => {
- let data = resp.data;
- this.form = data;
- this.customer.index = this.customer.customerList.map(obj => obj.name).indexOf(data
- .customerName);
- this.goods.index = this.goods.goodsList.map(o => o.name).indexOf(data.goodsName);
- let items = data.items;
- let names = items.map(obj => obj.itemTypeName);
- let itemTypeList = this.itemList.filter(obj => names.indexOf(obj.name) !== -1);
- for (let i in itemTypeList) {
- let type = itemTypeList[i];
- for (let j in items) {
- let item = items[j];
- if (item.itemTypeId == type.id) {
- type.itemName = item.itemName;
- type.num = item.num
- break;
- }
- }
- }
- setTimeout(() => {
- this.car.carInput = false;
- }, 50)
- })
- },
- addHsFn() {
- this.hs.visible = true;
-
- },
- showHsModal() {
- Object.assign(this.modal, {
- visible: true,
- form: {
- name: '',
- phone: '',
- index: -1
- }
- });
- },
- addHsPeopleFn() {
- if (!this.modal.form.name) {
- this.$common.toast('请输入名称');
- return;
- }
- if (!this.modal.form.phone) {
- this.$common.toast('请输入联系号码');
- return;
- }
- let dbIndex = this.modal.form.index;
- if (dbIndex >= 0) {
- this.hs.list[dbIndex].name = this.modal.form.name;
- this.hs.list[dbIndex].phone = this.modal.form.phone;
- } else {
- this.modal.form.index = this.hs.list.length;
- this.hs.list.push(this.modal.form);
- }
- this.modal.visible = false;
- this.handler();
- },
- editFn(data) {
- Object.assign(this.modal, {
- visible: true,
- form: data
- })
- },
- deleteFn(data) {
- this.hs.list.splice(data.index, 1);
- if (data.id) {
- this.$api.deleteHsPeople({
- id: data.id
- });
- }
- },
- getGoodsList() {
- this.$api.getGoodsList().then(resp => {
- this.goods.goodsList = resp.data;
- })
- },
- getDriverList() {
- this.$api.getDriverList().then(resp => {
- this.driverList = resp.data;
- })
- },
- idCardInput() {
- let val = this.form.driverIdCard;
- let list = this.driverList.filter(obj => obj.idCard.indexOf(val) !== -1);
- if (list.length > 0 && val) {
- this.driver.show = true;
- this.driver.filterList = list;
- } else {
- this.driver.show = false;
- }
- },
- selectDriverFn(item) {
- this.form.driverIdCard = item.idCard;
- this.form.driverName = item.name;
- this.form.driverPhone = item.phone
- let that = this;
- setTimeout(() => {
- that.driver.show = false;
- }, 150)
- },
- getCarList() {
- this.$api.getCarList().then(resp => {
- this.carList = resp.data;
- })
- },
- carInputFn() {
- let val = this.form.cardNo;
- let list = this.carList.filter(obj => obj.cardNo.indexOf(val) !== -1);
- if (list.length > 0 && val) {
- this.car.carInput = true;
- this.car.filterList = list;
- } else {
- this.car.carInput = false;
- }
- this.handler();
- },
- selectCarNo(item) {
- this.form.cardNo = item.cardNo;
- this.form.cardSize = item.cardSize;
- this.form.netWeight = item.lastNetWeight;
- let names = this.goods.goodsList.map(obj => obj.name);
- let index = names.indexOf(item.lastGoodsName);
- this.goods.index = index == -1 ? 0 : index;
- this.country.index = this.country.list.indexOf(item.countryName)
- let that = this;
- this.handler();
- setTimeout(() => {
- this.car.carInput = false;
- }, 150)
- },
- getCustomerList() {
- this.$api.getCustomerList().then(resp => {
- this.customer.customerList = resp.data;
- })
- },
- getItemList() {
- this.$api.getItemList().then(resp => {
- this.itemList = resp.data;
- })
- },
- selectItemFn(item) {
- this.item = item;
- this.show = true;
- },
- itemSelectFn(data) {
- this.show = false;
- this.item.itemName = data;
- this.handler();
- },
- handler() {
- let goodsIndex = this.goods.index;
- let countryIndex = this.country.index;
- this.form.goodsName = this.goods.goodsList[goodsIndex].name;
- this.form.countryName = this.country.list[countryIndex];
- this.form.goodsIndex = goodsIndex;
- this.form.countryIndex = countryIndex;
- this.form.peopleJson = JSON.stringify(this.hs.list);
- let customerId = this.customerId;
- if (customerId == '1') {
- let customerIndex = this.customer.index;
- this.form.customerId = this.customer.customerList[customerIndex].id;
- this.form.customerIndex = customerIndex;
- }
- let that = this;
- uni.setStorage({
- key: 'business_' + customerId,
- data: that.form
- })
- },
- checkStore() {
- let customerId = this.customerId;
- let data = uni.getStorageSync('business_' + customerId)
- if (data) {
- let that = this;
- uni.showModal({
- title: '提示',
- content: '您上次录入数据未提交,是否继续?',
- cancelText: '重新录入',
- confirmText: '继续',
- success(res) {
- if (res.confirm) {
- that.rebackStore(data);
- } else {
- uni.removeStorageSync('business_' + customerId)
- }
- }
- })
- }
- },
- rebackStore(data) {
- this.form = data;
- this.goods.index = data.goodsIndex ? data.goodsIndex : 0;
- this.customer.index = data.customerIndex ? data.customerIndex : 0;
- this.country.index = data.countryIndex ? data.countryIndex : 0;
- this.hs.list = data.peopleJson ? JSON.parse(data.peopleJson) : []
- setTimeout(() => {
- this.car.carInput = false;
- this.driver.show = false;
- }, 150)
- },
- check() {
- this.handler();
- if (!this.form.cardNo) {
- this.$common.toast('请录入境外车牌号')
- return false;
- }
- if (!this.form.cardSize) {
- this.$common.toast('请录入车辆规格')
- return false;
- }
- if (!this.form.chinaCarNo) {
- this.$common.toast('请录入中国车牌')
- return false;
- }
- if (!this.form.driverName) {
- this.$common.toast('请录入中国司机')
- return false;
- }
- if (!this.form.driverPhone) {
- this.$common.toast('请录入司机联系号码')
- return false;
- }
- let typeList = this.itemList.filter(obj => obj.itemName);
- if (typeList.length == 0) {
- this.$common.toast('至少选择一项业务项')
- return false;
- }
- if (typeList.filter(obj => obj.name.indexOf('核酸') !== -1).length > 0 && this.hs.list.length == 0) {
- this.$common.toast('录入核酸检测人员')
- return false;
- }
- let list = [];
- for (let i in typeList) {
- let type = typeList[i];
- type.num = 1;
- for (let j in type.items) {
- let item = type.items[j];
- if (type.itemName == item.itemName) {
- type.itemId = item.id;
- break;
- }
- }
- list.push({
- itemId: type.itemId,
- num: type.num
- })
- }
- this.form.itemJson = JSON.stringify(list);
- this.form.items = null;
- if (this.customerId == '1') {
- this.form.customerId = this.customer.customerList[this.customer.index].id;
- } else {
- this.form.customerId = this.customerId;
- }
- return true;
- },
- saveFn() {
- if (this.check()) {
- let obj = this.$common.removeNull(this.form);
- this.$api.saveBusiness(obj).then(resp => {
- if (resp.code == 200) {
- uni.removeStorageSync('business_' + this.customerId);
- this.$common.toast('录入成功');
- this.hs.list = [];
- setTimeout(() => {
- this.$common.to('/pages/business-order/business-order')
- }, 1000)
- }
- })
- }
- },
- bindPickerChange(e) {
- var nowId = e.target.id; //当前picker的ID id需要自己设置 在picker中
- var value = e.detail.value; //当前picker选中的值
- switch (nowId) { //根据ID判断是哪个picker
- case "qy": //picker的ID
- this.customer.index = value;
- break;
- case "hw": //picker的ID
- this.goods.index = value;
- break;
- case "gj": //picker的ID
- this.country.index = value;
- break;
- }
- this.handler();
- },
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #fff;
- }
- .hs-item {
- text-align: center;
- }
- .item-line {
- color: #a2a2a2;
- padding: 5px 0 10px 29px;
- border-bottom: 1px solid #E5E5E5;
- }
- .hj {
- padding: 50rpx;
- font-size: 40rpx;
- color: red;
- font-weight: bold;
- }
- .save-btn {
- background-color: #ff4200;
- height: 88rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- margin: 60rpx;
- color: #fff;
- font-size: 30rpx;
- font-weight: bold;
- border-radius: 10rpx;
- }
- @import '@/common/common.scss'
- </style>
|