123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <template>
- <view>
- <view class="box">
- <view class="top">
- <text class="title">{{itemType.name}}</text>
- </view>
- <view class="item-line">
- 基本信息
- </view>
- <view class="item" v-if="!customerId||customerId=='1'">
- <view class="l"><text style="color: red;">*</text>客户:</view>
- <view class="r">
- <picker v-if="customer.list.length>0" class="p-picker" @change="customerChange($event)"
- :value="customer.index" :range="customer.list" range-key="name">
- <text class="p-text">{{customer.list[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"><text style="color: red;">*</text>车牌号:</view>
- <view class="r">
- <u-input placeholder="请填写车牌号" v-model="form.carNo" />
- </view>
- </view>
- <view class="item">
- <view class="l"><text style="color: red;">*</text>车辆类型:</view>
- <view class="r">
- <picker class="p-picker" id="qy" @change="bindPickerChange($event)" :value="type.index"
- :range="type.list" range-key="name">
- <text class="p-text">{{type.list[type.index]}}</text>
- <u-icon class="p-icon" name="arrow-down-fill" size="20"></u-icon>
- </picker>
- </view>
- </view>
- <view class="item">
- <view class="l"><text style="color: red;">*</text>车辆规格:</view>
- <view class="r">
- <u-input placeholder="请填写车辆规格" v-model="form.carSize" />
- </view>
- </view>
- <view class="item" v-if="type.index==1">
- <view class="l">载重(kg):</view>
- <view class="r">
- <u-input placeholder="请填写车辆载重" v-model="form.carWeight" />
- </view>
- </view>
- <view class="item-line">
- 收费明细<text style="color: red;">(总共{{totalPrice}}元)</text>
- </view>
- <u-checkbox-group v-model="checkList" placement="column">
- <uni-list v-for="item in itemType.items">
- <uni-list-item style="display: inline;" :title="item.itemName" :note="item.price+''+item.unit">
- <template v-slot:header>
- <u-checkbox :name="item.id" :disabled="item.need==1" style="display: inline;">
- </u-checkbox>
- </template>
- <template v-slot:footer>
- <div style="position: absolute;right: 230rpx;top: 65rpx;">
- <u-number-box :disabled="item.inc==0" v-model="item.num">
- <view slot="minus" class="minus">
- <u-icon name="minus" size="12"></u-icon>
- </view>
- <text v-if="item.inc==0" slot="input"
- style="width: 50px;text-align: center;color: #E5E5E5;"
- class="input">{{item.num}}</text>
- <text v-else slot="input" style="width: 50px;text-align: center;"
- class="input">{{item.num}}</text>
- <view slot="plus" class="plus">
- <u-icon name="plus" size="12"></u-icon>
- </view>
- </u-number-box>
- </div>
- <u-button v-show="item.needRemark" @click="openRemarkFn(item)" style="width: 50px;"
- type="primary" size="mini" text="备注"></u-button>
- </template>
- </uni-list-item>
- </uni-list>
- </u-checkbox-group>
- </view>
- <view v-if="!form.adminConfirmInput">
- <u-button type="primary" text="修改" @click="saveFn"></u-button>
- </view>
- <!-- ---------------------------------------------------------- -->
- <view class="bottom-safety"></view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- showRemark: false,
- type: {
- index: 1,
- list: ['空车', '载货']
- },
- customerId: '1',
- customer: {
- index: 0,
- list: []
- },
- form: {
- carNo: '',
- carSize: '',
- carWeight: ''
- },
- list: [],
- checkList: [],
- businessItems: [],
- itemType: {
- id: '',
- name: '',
- items: []
- }
- }
- },
- computed: {
- totalPrice() {
- let items = this.itemType.items;
- let checkList = this.checkList;
- items = items.filter(obj => checkList.indexOf(obj.id) !== -1);
- let price = 0;
- for (let i in items) {
- let item = items[i];
- price = price + item.price * item.num;
- }
- return price;
- }
- },
- onLoad(options) {
- this.form.id = options.id;
- this.getOtherBusinessById();
- this.customerId = uni.getStorageSync('customerId');
- let that = this;
- uni.$on('getRemark', data => {
- that.$nextTick(function() {
- let items = that.itemType.items;
- items.filter(obj => obj.id == data.itemId)[0].remark = data.remark;
- })
- })
- },
- onBackPress() {
- this.$common.to('/pages/onely-disinfect/Index');
- return true;
- },
- methods: {
- getCustomerList() {
- let p = {
- judgeStatus: 2,
- pageNo: 1,
- pageSize: 30,
- type: 0
- }
- this.$api.getCustomerList(p).then(resp => {
- let list = resp.data;
- this.customer.list = list;
- console.log(list)
- this.customer.index = list.map(obj => obj.id).indexOf(this.form.customerId);
- })
- },
- openRemarkFn(data) {
- this.$common.to('/pages/onely-disinfect/add-remark?itemId=' + data.id + '&title=' + data.itemName +
- '&remark=' + data.remark + '&mustRemark=' + data.mustRemark)
- },
- closeFn() {
- this.$refs.popup.close()
- },
- getItemType() {
- this.$api.getItemType({
- id: this.itemType.id
- }).then(resp => {
- let data = resp.data;
- this.itemType = data;
- let items = data.items;
- let businessItems = this.businessItems;
- items.forEach(obj => {
- businessItems.forEach(item => {
- if (obj.id == item.itemId) {
- obj.remark = item.remark;
- obj.num = item.num;
- }
- })
- })
- })
- },
- bindPickerChange(e) {
- let index = e.detail.value;
- this.type.index = index //当前picker选中的值
- },
- customerChange(e) {
- let index = e.detail.value;
- this.customer.index = index //当前picker选中的值
- },
- saveFn() {
- if (!this.form.carNo) {
- this.$common.toast('请输入车牌号')
- return;
- }
- if (!this.$common.isNum(this.form.carSize)) {
- this.$common.toast('请输入正确的规格')
- return;
- }
- if (this.type.index == 1 && !this.$common.isNum(this.form.carWeight)) {
- this.$common.toast('请输正确的载重')
- return;
- }
- let itemList = this.itemType.items;
- let checkList = this.checkList;
- let list = itemList.filter(obj => checkList.indexOf(obj.id) !== -1);
- this.form.itemTypeId = this.itemType.id;
- this.form.items = list;
- this.form.carType = this.type.list[this.type.index]
- if (this.customerId == '1') {
- this.form.customerId = this.customer.list[this.customer.index].id;
- } else {
- this.form.customerId = this.customerId
- }
- let that = this;
- let content = '确认修改该业务'
- uni.showModal({
- title: '提示',
- content: content,
- success(res) {
- if (res.confirm) {
- that.editFn()
- }
- }
- })
- },
- getOtherBusinessById() {
- this.$api.getOtherBusinessById({
- id: this.form.id
- }).then(resp => {
- let data = resp.data;
- this.form = data;
- this.businessItems = data.items;
- this.checkList = data.items.map(obj => obj.itemId);
- this.itemType.id = data.itemTypeId;
- this.type.index = this.type.list.indexOf(data.carType)
- this.getItemType();
- this.getCustomerList();
- })
- },
- editFn() {
- this.$api.editCarDisinfect(this.$common.removeNull(this.form)).then(resp => {
- if (resp.code == 200) {
- this.$common.toast('修改成功');
- setTimeout(() => {
- this.$common.to('/pages/onely-disinfect/Index')
- }, 1500)
- }
- })
- }
- },
- }
- </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>
|