484 lines
18 KiB
Vue
484 lines
18 KiB
Vue
<template>
|
|
<view class="layout layout-ident">
|
|
<text class="text-main font-bold mb-20">加工商状态: {{
|
|
(isNaN(factoryStatus) || factoryStatus === -1) ? '未提交审核' : (factoryStatus === 0 ? '审核中' : (factoryStatus === 1 ? '审核通过' : `审核不通过:${refuseReason}`))
|
|
}}
|
|
</text>
|
|
<view class="form-box">
|
|
<el-divider>
|
|
<text class="text-50 text-main font-bold">工厂信息</text>
|
|
</el-divider>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">成立年限</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
:dis="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.year"
|
|
>
|
|
<template #suffix>年</template>
|
|
</u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">年产值</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.yearsIncome"
|
|
>
|
|
<template #suffix>万元</template>
|
|
</u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">员工人数</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.employeeNum"
|
|
>
|
|
<template #suffix>人</template>
|
|
</u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">流水线数量</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.flowNum"
|
|
>
|
|
<template #suffix>条</template>
|
|
</u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">厂房归属</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.blongTo"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">厂房面积</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.size"
|
|
>
|
|
<template #suffix>平方米</template>
|
|
</u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30" @click="showAddress">
|
|
<view class="lb need">所在地</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
placeholder="请选择公司所在地"
|
|
v-model="addressRegion"
|
|
suffixIcon="arrow-down"
|
|
suffixIconStyle="color: #909399"
|
|
disabled
|
|
disabledColor="#fff"
|
|
style="pointer-events:none"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">主营工艺和业务范围</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.mainProcess"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">服务信息</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.serviceInfo"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<el-divider>
|
|
<text class="text-50 text-main font-bold">视频</text>
|
|
</el-divider>
|
|
<view class="m-top-20">
|
|
<u-upload
|
|
accept="video"
|
|
:fileList="form.video"
|
|
@afterRead="afterReadVideo"
|
|
@delete="deletePicVideo"
|
|
:maxCount="1"
|
|
width="70"
|
|
height="70"
|
|
></u-upload>
|
|
</view>
|
|
<el-divider>
|
|
<text class="text-50 text-main font-bold">设备信息</text>
|
|
</el-divider>
|
|
<view v-for="(item, index) in form.deviceList" :key="index" class="rounded shadow p-30 mb-20">
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">设备名称</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.deviceList[index].name"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">设备数量</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.deviceList[index].num"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">设备来源</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.deviceList[index].source"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">设备类型</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.deviceList[index].type"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">品牌</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.deviceList[index].brand"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">型号</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.deviceList[index].model"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">投产年限</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.deviceList[index].year"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="group flex align-center m-top-30">
|
|
<view class="lb need">特点描述</view>
|
|
<view class="vl flex-1">
|
|
<u--input
|
|
:readonly="factoryStatus === 0"
|
|
placeholder="请输入内容"
|
|
v-model="form.deviceList[index].desc"
|
|
></u--input>
|
|
</view>
|
|
</view>
|
|
<view class="flex justify-center mt-20">
|
|
<view class="flex-1 px-20">
|
|
<u-button size="small" color="#A92924" :plain="true" text="删除"
|
|
@click="remove(index)"></u-button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<u-button size="small" color="#A92924" text="添加设备"
|
|
@click="addDevice"></u-button>
|
|
<el-divider>
|
|
<text class="text-50 text-main font-bold">工厂实景</text>
|
|
</el-divider>
|
|
<view class="m-top-20">
|
|
<u-upload
|
|
:fileList="album"
|
|
@afterRead="afterRead"
|
|
@delete="deletePic"
|
|
multiple
|
|
:maxCount="10"
|
|
width="70"
|
|
height="70"
|
|
></u-upload>
|
|
</view>
|
|
<u-button size="small" color="#A92924" text="提交"
|
|
@click="submit"></u-button>
|
|
</view>
|
|
<AddressSelect ref="AddressSelect" @confirm="regionConfirm"/>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import AddressSelect from "@/components/AddressSelect.vue";
|
|
import dayjs from "dayjs";
|
|
import md5 from "js-md5";
|
|
|
|
export default {
|
|
name: "factory",
|
|
components: {AddressSelect},
|
|
props: {
|
|
userData: {
|
|
type: Object
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
formData: {
|
|
test: ''
|
|
},
|
|
form: {
|
|
year: null,
|
|
yearsIncome: null,
|
|
employeeNum: null,
|
|
flowNum: null,
|
|
blongTo: null,
|
|
size: null,
|
|
addressRegion: {
|
|
province: null,
|
|
city: null,
|
|
},
|
|
mainProcess: null,
|
|
serviceInfo: null,
|
|
deviceList: [],
|
|
album: [],
|
|
video: [],
|
|
},
|
|
options: [],
|
|
addressRegion: '',
|
|
deviceSource: ['国产', '进口'],
|
|
deviceType: ['生产设备', '维护设备'],
|
|
userLevel: {
|
|
factoryPicNum: 0
|
|
},
|
|
factoryStatus: this.userData.factoryStatus,
|
|
refuseReason: '',
|
|
album: []
|
|
}
|
|
},
|
|
methods: {
|
|
showAddress() {
|
|
this.$refs.AddressSelect.open(this.form.addressRegion, 2);
|
|
},
|
|
regionConfirm({province, city}) {
|
|
this.form.addressRegion = {province, city}
|
|
this.addressRegion = `${province.name}${city.name}`
|
|
},
|
|
addDevice() {
|
|
this.form.deviceList.push({
|
|
name: null,
|
|
num: null,
|
|
source: null,
|
|
type: null,
|
|
brand: null,
|
|
model: null,
|
|
year: null,
|
|
desc: null
|
|
})
|
|
},
|
|
remove(index) {
|
|
this.form.deviceList.splice(index, 1)
|
|
},
|
|
async getUserLevelInfo() {
|
|
const res = await vk.callFunction({
|
|
url: "client/userLevel/kh/getInfoByUser",
|
|
})
|
|
if (res) {
|
|
if (!res.data) {
|
|
this.$message.error('请先完成认证')
|
|
setTimeout(() => {
|
|
uni.navigateBack()
|
|
}, 1000)
|
|
return
|
|
}
|
|
}
|
|
},
|
|
async submit() {
|
|
if (!this.form.year) return this.$message.error('请输入投产年限')
|
|
if (!this.form.yearsIncome) return this.$message.error('请输入年收入')
|
|
if (!this.form.employeeNum) return this.$message.error('请选输入员工人数')
|
|
if (!this.form.flowNum) return this.$message.error('请输入流水线数量')
|
|
if (!this.form.blongTo) return this.$message.error('请输入厂房归属')
|
|
if (!this.form.size) return this.$message.error('请输入厂房面积')
|
|
if (!this.addressRegion) return this.$message.error('请选择所在地')
|
|
if (this.form.deviceList.length === 0) return this.$message.error('请添加设备信息')
|
|
if (this.form.album.length === 0) return this.$message.error('请上传工厂实景图')
|
|
if (this.form.video.length > 0) this.form.video = this.form.video.map(item => item.url)
|
|
await vk.callFunction({
|
|
url: "client/factory/kh/addUpdate",
|
|
data: this.form
|
|
})
|
|
this.$message.success('提交成功')
|
|
this.factoryStatus = 0
|
|
},
|
|
async getInfo() {
|
|
const res = await vk.callFunction({
|
|
url: "client/factory/kh/getInfo",
|
|
})
|
|
if (res) {
|
|
for (let key in this.form) this.form[key] = res[key]
|
|
this.addressRegion = `${res.addressRegion.province.name}${res.addressRegion.city.name}`
|
|
if (res.status === 2) this.refuseReason = res.refuseReason
|
|
if (this.form.album && this.form.album.length > 0) {
|
|
this.album = this.form.album.map(url => {
|
|
return {
|
|
url
|
|
}
|
|
})
|
|
}
|
|
if (this.form.video) this.form.video = [{url: this.form.video[0]}]
|
|
console.log(this.form.video)
|
|
}
|
|
},
|
|
afterRead({file}) {
|
|
file.forEach(item => {
|
|
console.log(item)
|
|
uniCloud.uploadFile({
|
|
filePath: item.url,
|
|
cloudPath: dayjs().format('YYYY/MM/DD') + '/' + item.name,
|
|
success: ({fileID}) => {
|
|
uniCloud.getTempFileURL({
|
|
fileList: [fileID]
|
|
}).then(res => {
|
|
this.album.push({url: res.fileList[0].tempFileURL})
|
|
this.form.album.push(res.fileList[0].tempFileURL)
|
|
})
|
|
}
|
|
})
|
|
})
|
|
},
|
|
deletePic({index}) {
|
|
this.album.splice(index, 1)
|
|
this.form.album.splice(index, 1)
|
|
},
|
|
afterReadVideo({file}) {
|
|
console.log(file.type)
|
|
if (file.type !== 'video/mp4' && file.type !== 'video') {
|
|
uni.showToast({
|
|
title: '请上传MP4文件',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
uniCloud.uploadFile({
|
|
filePath: file.url,
|
|
cloudPath: dayjs().format('YYYY/MM/DD') + '/' + md5(file.name + Date.now().toString()) + '.mp4',
|
|
success: ({fileID}) => {
|
|
uniCloud.getTempFileURL({
|
|
fileList: [fileID]
|
|
}).then(res => {
|
|
this.form.video = [{url: res.fileList[0].tempFileURL}]
|
|
})
|
|
}
|
|
})
|
|
},
|
|
deletePicVideo() {
|
|
this.form.video = []
|
|
},
|
|
},
|
|
mounted() {
|
|
this.getUserLevelInfo()
|
|
vk.userCenter.getCurrentUserInfo({
|
|
success: (data) => {
|
|
const factoryStatus = parseInt(data.userInfo.factoryStatus)
|
|
this.factoryStatus = (isNaN(factoryStatus) || factoryStatus === -1) ? -1 : factoryStatus
|
|
if (this.factoryStatus > -1) this.getInfo()
|
|
}
|
|
})
|
|
},
|
|
computed: {
|
|
deviceNum() {
|
|
let num = 0
|
|
this.form.deviceList.forEach(item => {
|
|
if (item.num && !isNaN(parseInt(item.num))) num += parseInt(item.num)
|
|
})
|
|
return num
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
.layout-ident {
|
|
padding: 20rpx 30rpx;
|
|
|
|
.group {
|
|
display: flex;
|
|
justify-content: flex-start;
|
|
align-items: center;
|
|
}
|
|
|
|
.lb, .fix {
|
|
position: relative;
|
|
min-width: 150rpx;
|
|
font-size: 26rpx;
|
|
line-height: 40rpx;
|
|
color: #666666;
|
|
}
|
|
|
|
.lbx {
|
|
font-size: 24rpx;
|
|
color: #999999;
|
|
}
|
|
|
|
.download {
|
|
padding: 8rpx 20rpx;
|
|
font-size: 24rpx;
|
|
line-height: 36rpx;
|
|
color: #ffffff;
|
|
background: #A92924;
|
|
}
|
|
|
|
.need::before {
|
|
position: absolute;
|
|
left: -16rpx;
|
|
top: 50%;
|
|
z-index: 9;
|
|
margin-top: -12rpx;
|
|
content: '*';
|
|
color: #A92924;
|
|
font-size: 32rpx;
|
|
line-height: 1;
|
|
}
|
|
}
|
|
|
|
.public-btn {
|
|
width: 100%;
|
|
margin-top: 60rpx;
|
|
color: #ffffff;
|
|
background: #A92924;
|
|
}
|
|
</style> |