|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
<template> |
|
|
|
|
<view class="v-pages"> |
|
|
|
|
<view class="v-form v-container"> |
|
|
|
|
<uni-forms :modelValue="formData" ref="formRef" :label-width="120" :rules="formRules"> |
|
|
|
|
<view class="v-form v-container" style="padding-bottom: 120rpx;"> |
|
|
|
|
<uni-forms :modelValue="formData" ref="formRef" :label-width="80" :rules="formRules"> |
|
|
|
|
<view class="v-form-item base" @click="goBase()"> |
|
|
|
|
<view class="row"> |
|
|
|
|
<view class="col">切换基地</view> |
|
|
|
@ -14,8 +14,7 @@ |
|
|
|
|
<input v-model="formData.baseName" placeholder="请输入基地名称" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item label="所属企业" name="companyId"> |
|
|
|
|
<picker @change="CompanyChange" v-model="formData.companyId" mode='selector' |
|
|
|
|
:value="CurrentCompany" :range="CompanyPickerList"> |
|
|
|
|
<picker @change="CompanyChange" :value="CurrentCompany" :range="CompanyPickerList"> |
|
|
|
|
<view class="uni-input" v-if="CompanyPickerList[CurrentCompany]"> |
|
|
|
|
{{CompanyPickerList[CurrentCompany]}} |
|
|
|
|
</view> |
|
|
|
@ -37,26 +36,29 @@ |
|
|
|
|
<uni-forms-item label="基地地址" name="baseAddress"> |
|
|
|
|
<input v-model="formData.baseAddress" placeholder="请输入基地地址" class="m-form-small" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item label="基地面积(亩)" name="baseArea"> |
|
|
|
|
<uni-forms-item label="基地面积(亩)" name="baseArea":label-width="120"> |
|
|
|
|
<input v-model="formData.baseArea" placeholder="请输入联系电话" class="m-form-small" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item label="负责人" name="baseLeader"> |
|
|
|
|
<input v-model="formData.baseLeader" placeholder="请输入联系电话" class="m-form-small" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item label="联系电话" name="basePhone"> |
|
|
|
|
<input v-model="formData.basePhone" placeholder="请输入联系电话" class="m-form-small" /> |
|
|
|
|
<input v-model="formData.basePhone" placeholder="请输入联系电话" type="digit" class="m-form-small" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item label="基地简介" name="baseDescription"> |
|
|
|
|
<rich-text :nodes="formData.baseDescription"></rich-text> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item label="基地图片" name="baseImage"> |
|
|
|
|
<image class="v-base-img" :src="formData.baseImage"></image> |
|
|
|
|
|
|
|
|
|
<htz-image-upload v-model="imgList" :action="baseUrls" :chooseNum="1" :compress="false" |
|
|
|
|
:headers="headers" :max="1" :quality="80" :remove="true" :sourceType="['album', 'camera']" |
|
|
|
|
class="m-img-upload" mediaType="image" @imgDelete="ceshiImgDelete" |
|
|
|
|
@uploadFail="ceshiUploadFail" @uploadSuccess="ceshiUploadSuccess"></htz-image-upload> |
|
|
|
|
<uni-easyinput v-model="formData.companyLicense" class="not-show" placeholder=" " /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
</view> |
|
|
|
|
</uni-forms> |
|
|
|
|
<!-- 页面 提交 --> |
|
|
|
|
<view class="sticky fixedBottom"><button class="v-primary-btn large" @click="submitForm()">保存</button> |
|
|
|
|
<view class="fixed fixedBottom v-container"><button class="v-primary-btn large" @click="submitForm()">保存</button> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -71,12 +73,26 @@ |
|
|
|
|
|
|
|
|
|
import cityPicker from '@/uni_modules/piaoyi-cityPicker/components/piaoyi-cityPicker/piaoyi-cityPicker' |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
getAccessToken |
|
|
|
|
} from '@/utils/auth'; |
|
|
|
|
import config from '@/config'; |
|
|
|
|
import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
components: { |
|
|
|
|
cityPicker |
|
|
|
|
cityPicker, |
|
|
|
|
htzImageUpload |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
imgList: [], |
|
|
|
|
baseUrls: config.baseUrl + config.baseApi + '/infra/file/upload', |
|
|
|
|
headers: { |
|
|
|
|
Authorization: 'Bearer ' + getAccessToken() |
|
|
|
|
}, // 设置上传的请求头部 |
|
|
|
|
|
|
|
|
|
defaultValue: '', |
|
|
|
|
column: 3, |
|
|
|
|
startVisible: false, |
|
|
|
@ -90,7 +106,6 @@ |
|
|
|
|
cityCode: null, |
|
|
|
|
cityCode: null, |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
formData: { |
|
|
|
|
id: undefined, |
|
|
|
|
baseName: undefined, |
|
|
|
@ -141,11 +156,17 @@ |
|
|
|
|
errorMessage: '请输入基地面积' |
|
|
|
|
}] |
|
|
|
|
}, |
|
|
|
|
baseAddress: { |
|
|
|
|
rules: [{ |
|
|
|
|
required: true, |
|
|
|
|
errorMessage: '请输入基地详细地址' |
|
|
|
|
}] |
|
|
|
|
}, |
|
|
|
|
basePhone: { |
|
|
|
|
rules: [{ |
|
|
|
|
required: true, |
|
|
|
|
errorMessage: '请输入联系电话' |
|
|
|
|
}] |
|
|
|
|
}, ] |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -153,6 +174,10 @@ |
|
|
|
|
CurrentCompany: undefined, |
|
|
|
|
CompanyList: [], //所属企业列表 |
|
|
|
|
CompanyPickerList: [], //所属企业选择列表 |
|
|
|
|
|
|
|
|
|
provinceList: [], |
|
|
|
|
cityList: [], |
|
|
|
|
areaList: [], |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onLoad: function() { |
|
|
|
@ -163,36 +188,49 @@ |
|
|
|
|
this.$refs.formRef.setRules(this.formRules) |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
async getCity() { |
|
|
|
|
async getAddressList() { |
|
|
|
|
try { |
|
|
|
|
const res = await areaApi.getAreaTree() |
|
|
|
|
this.addressList = res.data |
|
|
|
|
|
|
|
|
|
} finally {} |
|
|
|
|
}, |
|
|
|
|
// 获取产品数据 |
|
|
|
|
async getListData() { |
|
|
|
|
this.getCity() |
|
|
|
|
try { |
|
|
|
|
this.getCompany() |
|
|
|
|
await this.getCompany() |
|
|
|
|
await this.getAddressList() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const res = await BaseApi.getBase(this.baseId) |
|
|
|
|
this.formData = res.data |
|
|
|
|
this.CurrentCompany = this.CompanyList.findIndex(item => Number(item.companyId) === |
|
|
|
|
Number(this.formData.companyId)) |
|
|
|
|
|
|
|
|
|
console.log("aaaaa", this.addressList) |
|
|
|
|
const province=this.addressList.find((item, index) => { |
|
|
|
|
// 初始化当前公司 |
|
|
|
|
this.CompanyList.map((item, index, arr) => { |
|
|
|
|
if (item.companyId === this.formData.companyId) { |
|
|
|
|
this.CurrentCompany = index |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.provinceList = this.addressList.find((item, index) => { |
|
|
|
|
return item.id == this.formData.province; |
|
|
|
|
}) |
|
|
|
|
console.log(province) |
|
|
|
|
this.LocalData.provinceName =province.name |
|
|
|
|
|
|
|
|
|
this.LocalData.cityName = this.formData.city |
|
|
|
|
this.LocalData.areaName = this.formData.district |
|
|
|
|
this.cityList = this.provinceList.children.find((item, index) => { |
|
|
|
|
return item.id == this.formData.city; |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.areaList = this.cityList.children.find((item, index) => { |
|
|
|
|
return item.id == this.formData.district; |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.LocalData.provinceName = this.provinceList.name |
|
|
|
|
this.LocalData.cityName = this.cityList.name |
|
|
|
|
this.LocalData.areaName = this.areaList.name |
|
|
|
|
|
|
|
|
|
this.LocalData.provinceCode = this.formData.province |
|
|
|
|
this.LocalData.cityCode = this.formData.city |
|
|
|
|
this.LocalData.areaCode = this.formData.district |
|
|
|
|
this.imgList[0]=this.formData.baseImage |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} finally {} |
|
|
|
@ -202,15 +240,20 @@ |
|
|
|
|
async submitForm() { |
|
|
|
|
// 校验主表 |
|
|
|
|
try { |
|
|
|
|
const that = this |
|
|
|
|
await this.$refs['formRef'].validate() |
|
|
|
|
const data = this.formData |
|
|
|
|
await BaseApi.updateBase(data) |
|
|
|
|
console.log(this.formData) |
|
|
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
|
title: `保存成功`, |
|
|
|
|
icon: 'success', |
|
|
|
|
duration: 2000, |
|
|
|
|
complete: function() { |
|
|
|
|
setTimeout(function() { |
|
|
|
|
that.$store.dispatch('changeBaseName',that.formData.baseName) |
|
|
|
|
that.$store.dispatch('changeBaseLeader',that.formData.baseLeader) |
|
|
|
|
uni.redirectTo({ |
|
|
|
|
url: '/pages/mine/index' |
|
|
|
|
}); |
|
|
|
@ -245,6 +288,7 @@ |
|
|
|
|
// 选择所属企业 |
|
|
|
|
CompanyChange(e) { |
|
|
|
|
this.CurrentCompany = e.detail.value |
|
|
|
|
this.formData.companyId = this.CompanyList[this.CurrentCompany].companyId |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
//配送地址 |
|
|
|
@ -252,17 +296,33 @@ |
|
|
|
|
this.startVisible = true |
|
|
|
|
}, |
|
|
|
|
startConfirm(val) { |
|
|
|
|
console.log(val) |
|
|
|
|
this.LocalData = val |
|
|
|
|
this.startVisible = false |
|
|
|
|
this.formData.startRegion = this.LocalData.name |
|
|
|
|
this.formData.startProvince = this.LocalData.provinceCode |
|
|
|
|
this.formData.startCity = this.LocalData.cityCode |
|
|
|
|
this.formData.startCountry = this.LocalData.areaCode |
|
|
|
|
this.formData.province = this.LocalData.provinceCode |
|
|
|
|
this.formData.city = this.LocalData.cityCode |
|
|
|
|
this.formData.district = this.LocalData.areaCode |
|
|
|
|
}, |
|
|
|
|
startCancel() { |
|
|
|
|
this.startVisible = false |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
ceshiUploadSuccess(res) { |
|
|
|
|
//上传成功 |
|
|
|
|
var _res = JSON.parse(res.data); |
|
|
|
|
console.log('_res', _res); |
|
|
|
|
if (_res.code == 0) { |
|
|
|
|
this.imgList.push(_res.data); |
|
|
|
|
this.formData.baseImage = _res.data; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
ceshiImgDelete(e, num) { |
|
|
|
|
console.log('ceshiImgDelete', e); |
|
|
|
|
}, |
|
|
|
|
ceshiUploadFail(err) { |
|
|
|
|
//上传失败 |
|
|
|
|
console.log('err', err); |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|