541 lines
24 KiB
Vue
541 lines
24 KiB
Vue
<template>
|
|
<view class="border-bottom pt-20">
|
|
<el-form ref="form" :model="form1" label-width="140px" :rules="form1.props.rules">
|
|
<view class="flex flex-wrap justify-start items-start">
|
|
<view class="w-25p">
|
|
<el-form-item label="商品名称">
|
|
<el-select v-model="form1.data.goodsId" placeholder="请选择商品" @change="selectGoods">
|
|
<el-option
|
|
v-for="(item, index) in goodsList"
|
|
:key="index"
|
|
:label="item.name"
|
|
:value="item._id">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</view>
|
|
<view class="w-25p" v-for="(item, index) in goodsAttributes" :key="index">
|
|
<template v-if="goodsAttributes && goodsAttributes.length > 0">
|
|
<el-form-item :label="item.label" v-if="item.label">
|
|
<el-select v-model="form1.data.model[index].value" placeholder="请选择">
|
|
<el-option
|
|
v-for="(value, valueIndex) in item.values" :key="valueIndex" :label="value"
|
|
:value="value">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</template>
|
|
</view>
|
|
</view>
|
|
<el-row :gutter="10">
|
|
<!-- <el-col :span="10">-->
|
|
<!-- <el-form-item label="单件长度">-->
|
|
<!-- <el-input placeholder="请输入内容" v-model="form1.data.singleLength" class="input-with-select"-->
|
|
<!-- type="number">-->
|
|
<!-- <template slot="append">米</template>-->
|
|
<!--<!– <el-select v-model="form1.data.singleLengthUnit" slot="append" placeholder="请选择">–>-->
|
|
<!--<!– <template v-if=" attributes.find(attr => attr.label === '单件长度')">–>-->
|
|
<!--<!– <el-option–>-->
|
|
<!--<!– v-for="(item, index) in attributes.find(attr => attr.label === '单件长度').options"–>-->
|
|
<!--<!– :key="index"–>-->
|
|
<!--<!– :label="item.label"–>-->
|
|
<!--<!– :value="item.value">–>-->
|
|
<!--<!– </el-option>–>-->
|
|
<!--<!– </template>–>-->
|
|
<!--<!– </el-select>–>-->
|
|
<!-- </el-input>-->
|
|
<!-- </el-form-item>-->
|
|
<!-- </el-col>-->
|
|
<!-- <el-col :span="6">-->
|
|
<!-- <el-form-item label="尺寸">-->
|
|
<!-- <el-select v-model="form1.data.materialQuality" placeholder="请选择">-->
|
|
<!-- <template v-if=" attributes.find(attr => attr.label === '尺寸')">-->
|
|
<!-- <el-option-->
|
|
<!-- v-for="(item, index) in attributes.find(attr => attr.label === '尺寸').options"-->
|
|
<!-- :key="index"-->
|
|
<!-- :label="item.label"-->
|
|
<!-- :value="item.value">-->
|
|
<!-- </el-option>-->
|
|
<!-- </template>-->
|
|
<!-- </el-select>-->
|
|
<!-- </el-form-item>-->
|
|
<!-- </el-col>-->
|
|
<el-col :span="6">
|
|
<el-form-item label="交货服务">
|
|
<el-select v-model="form1.data.deliverService" placeholder="请选择">
|
|
<template v-if=" attributes.find(attr => attr.label === '交货服务')">
|
|
<el-option
|
|
v-for="(item, index) in attributes.find(attr => attr.label === '交货服务').options"
|
|
:key="index"
|
|
:label="item.label"
|
|
:value="item.value">
|
|
</el-option>
|
|
</template>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="6">
|
|
<el-form-item label="计价形式">
|
|
<el-select v-model="form1.data.pricingForm" placeholder="请选择">
|
|
<template v-if="attributes.find(attr => attr.label === '计价形式')">
|
|
<el-option
|
|
v-for="(item, index) in attributes.find(attr => attr.label === '计价形式').options"
|
|
:key="index"
|
|
:label="item.label"
|
|
:value="item.value">
|
|
</el-option>
|
|
</template>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row :gutter="10">
|
|
<el-col :span="12">
|
|
<el-form-item label="采购数量">
|
|
<el-input v-model="form1.data.procureNumber" class="input-with-select" type="number">
|
|
<el-select v-model="form1.data.procureUnit" slot="append" placeholder="请选择">
|
|
<template v-if=" attributes.find(attr => attr.label === '单位')">
|
|
<el-option
|
|
v-for="(item, index) in attributes.find(attr => attr.label === '单位').options"
|
|
:key="index"
|
|
:label="item.label"
|
|
:value="item.value">
|
|
</el-option>
|
|
</template>
|
|
</el-select>
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-form-item label="装货、卸货费用承担">
|
|
<el-select v-model="form1.data.loadPaidBy" placeholder="请选择" style="width: 100%">
|
|
<template v-if="attributes.find(attr => attr.label === '装货、卸货费用承担')">
|
|
<el-option
|
|
v-for="(item, index) in attributes.find(attr => attr.label === '装货、卸货费用承担').options"
|
|
:key="index"
|
|
:label="item.label"
|
|
:value="item.label">
|
|
</el-option>
|
|
</template>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
</el-form>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import provinces from "@/uni_modules/vk-uview-ui/libs/address/provinces.json";
|
|
import citys from "@/uni_modules/vk-uview-ui/libs/address/citys.json";
|
|
import areas from "@/uni_modules/vk-uview-ui/libs/address/areas.json";
|
|
|
|
export default {
|
|
props: {
|
|
value: {
|
|
type: Object,
|
|
default: () => {
|
|
return {}
|
|
}
|
|
},
|
|
baseAttributes: {
|
|
type: Array,
|
|
default: () => {
|
|
return []
|
|
}
|
|
},
|
|
productIndex: {
|
|
type: Number,
|
|
default: 0
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
pickerOptions: {
|
|
disabledDate(time) {
|
|
return time.getTime() < Date.now();
|
|
},
|
|
},
|
|
provinceData: provinces,
|
|
cityData: citys,
|
|
areaData: areas,
|
|
provinceIndex: null,
|
|
cityIndex: null,
|
|
areaIndex: null,
|
|
title: '商品',
|
|
attributesLoaded: false,
|
|
goodsList: [],
|
|
attributes: [],
|
|
goodsAttributes: [],
|
|
address: ['', '', ''],
|
|
form: {
|
|
addressDetail: ''
|
|
},
|
|
// 表单相关开始-----------------------------------------------------------
|
|
form1: {
|
|
// 表单请求数据,此处可以设置默认值
|
|
data: {
|
|
goodsId: null,
|
|
model: [],
|
|
otherData: null,
|
|
materialQuality: null,
|
|
singleLength: null,
|
|
singleLengthUnit: null,
|
|
deliverService: null,
|
|
standard: null,
|
|
pricingForm: null,
|
|
loadPaidBy: '供货方承担装车费用,采购方承担卸货费用',
|
|
deliveryTime: null,
|
|
len: null,
|
|
extraAttributes: {},
|
|
attributes: {},
|
|
addressRegion: [],
|
|
addressDetail: null
|
|
},
|
|
// 表单属性
|
|
props: {
|
|
// 表单请求地址
|
|
action: "client/enquiry/kh/add",
|
|
// 表单字段显示规则
|
|
columns: [
|
|
{key: "", title: "商品1", type: "bar-title", component: 'custom-form-section'},
|
|
{
|
|
key: "name",
|
|
title: "模板",
|
|
type: "remote-select",
|
|
action: "client/enquiry/template/pub/getList",
|
|
showAll: true,
|
|
actionData: {
|
|
pageSize: 1000
|
|
},
|
|
props: {
|
|
list: "rows",
|
|
value: "name",
|
|
label: "name"
|
|
},
|
|
watch: (res) => {
|
|
const {
|
|
option
|
|
} = res
|
|
console.log(option);
|
|
if (option.extraAttributes) {
|
|
let groupIndex = -1
|
|
option.extraAttributes.forEach((item, index) => {
|
|
if (index % 4 == 0) {
|
|
this.form1.props.columns[2].columns.push({
|
|
key: "",
|
|
title: "",
|
|
type: "group",
|
|
justify: "start",
|
|
showLabel: false,
|
|
columns: []
|
|
})
|
|
groupIndex++
|
|
}
|
|
|
|
this.form1.props.columns[2].columns[0].columns.push({
|
|
key: index,
|
|
title: item.label,
|
|
type: "select",
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: item.values.map(citem => {
|
|
return {
|
|
value: JSON.stringify({keyName: item.lable, keyValue: citem}),
|
|
label: citem
|
|
}
|
|
})
|
|
})
|
|
})
|
|
|
|
} else {
|
|
this.form1.props.columns[2].columns = []
|
|
}
|
|
}
|
|
},
|
|
{
|
|
key: "extraAttributes",
|
|
title: "额外属性",
|
|
type: "object",
|
|
justify: "start",
|
|
showLabel: false,
|
|
columns: [],
|
|
},
|
|
{
|
|
key: "",
|
|
title: "",
|
|
type: "group",
|
|
justify: "start",
|
|
showLabel: false,
|
|
columns: [
|
|
{
|
|
key: "brand",
|
|
title: "品牌厂家",
|
|
type: "select",
|
|
showAll: true,
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: () => {
|
|
const row = this.attributes.find(item => item.label == '品牌厂家')
|
|
if (row) {
|
|
return row.options
|
|
}
|
|
return [];
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
key: "materialQuality",
|
|
title: "材质",
|
|
type: "select",
|
|
showAll: true,
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: () => {
|
|
const row = this.attributes.find(item => item.label == '材质')
|
|
if (row) {
|
|
return row.options
|
|
}
|
|
return [];
|
|
}
|
|
|
|
},
|
|
{
|
|
key: "singleLength",
|
|
title: "单件长度",
|
|
type: "select",
|
|
showAll: true,
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: () => {
|
|
const row = this.attributes.find(item => item.label == '单件长度')
|
|
if (row) {
|
|
return row.options
|
|
}
|
|
return [];
|
|
}
|
|
|
|
},
|
|
{
|
|
key: "productStandard",
|
|
title: "产品标准",
|
|
type: "select",
|
|
showAll: true,
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: () => {
|
|
const row = this.attributes.find(item => item.label == '产品标准')
|
|
if (row) {
|
|
return row.options
|
|
}
|
|
return [];
|
|
}
|
|
|
|
},
|
|
],
|
|
},
|
|
|
|
{
|
|
key: "",
|
|
title: "",
|
|
type: "group",
|
|
justify: "start",
|
|
showLabel: false,
|
|
columns: [
|
|
|
|
{
|
|
key: "pricingForm",
|
|
title: "计价形式",
|
|
type: "select",
|
|
showAll: true,
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: () => {
|
|
const row = this.attributes.find(item => item.label == '计价形式')
|
|
if (row) {
|
|
return row.options
|
|
}
|
|
return [];
|
|
}
|
|
|
|
},
|
|
{
|
|
key: "processStandard",
|
|
title: "加工标准",
|
|
type: "select",
|
|
showAll: true,
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: () => {
|
|
const row = this.attributes.find(item => item.label == '加工标准')
|
|
if (row) {
|
|
return row.options
|
|
}
|
|
return [];
|
|
}
|
|
|
|
},
|
|
{
|
|
key: "deliveryService",
|
|
title: "交货服务",
|
|
type: "select",
|
|
showAll: true,
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: () => {
|
|
const row = this.attributes.find(item => item.label == '交货服务')
|
|
if (row) {
|
|
return row.options
|
|
}
|
|
return [];
|
|
}
|
|
|
|
},
|
|
{key: "deliveryTime", title: "交货时限", type: "date",},
|
|
],
|
|
},
|
|
|
|
|
|
{
|
|
key: "", title: "", type: 'group', showLabel: false, justify: "start", columns:
|
|
[
|
|
{key: "procureNumber", title: "采购数量", type: "number",},
|
|
{
|
|
key: "procureUnit",
|
|
title: "单位",
|
|
type: "select",
|
|
showAll: true,
|
|
allowCreate: true,
|
|
filterable: true,
|
|
data: () => {
|
|
const row = this.attributes.find(item => item.label == '单位')
|
|
if (row) {
|
|
return row.options
|
|
}
|
|
return [];
|
|
}
|
|
|
|
},
|
|
{key: "addressRegion", title: "交货地点", type: "address",},
|
|
{key: "addressDetail", title: "详细地址", type: "textarea",},
|
|
]
|
|
},
|
|
],
|
|
// 表单验证规则
|
|
rules: {
|
|
goodsId: [
|
|
{required: true, message: '商品不能为空', trigger: ["change", "blur"]}
|
|
],
|
|
addressRegion: [
|
|
{required: true, message: '交货地点不能为空', trigger: ["change", "blur"]}
|
|
],
|
|
procureNumber: [
|
|
{required: true, message: '采购数量不能为空', trigger: ["change", "blur"]},
|
|
{min: 1, type: 'number', message: '采购数量不能小于1', trigger: ["change", "blur"]}
|
|
],
|
|
procureUnit: [
|
|
{required: true, message: '采购数量不能为空', trigger: ["change", "blur"]},
|
|
],
|
|
|
|
},
|
|
// add 代表添加 update 代表修改
|
|
formType: "add",
|
|
// 表单是否在请求中
|
|
loading: false,
|
|
// 是否显示表单1 的弹窗
|
|
show: false,
|
|
beforeAction: (formData) => {
|
|
|
|
return false
|
|
}
|
|
}
|
|
},
|
|
// 表单相关结束-----------------------------------------------------------
|
|
}
|
|
},
|
|
created() {
|
|
this.form1.props.columns[0].title = '商品' + (this.productIndex + 1)
|
|
vk.callFunction({
|
|
url: 'client/enquiry/attributes/pub/getList',
|
|
title: '请求中...',
|
|
data: {},
|
|
success: (data) => {
|
|
this.attributes = data.rows
|
|
this.attributesLoaded = true
|
|
}
|
|
});
|
|
this.getGoodsList()
|
|
},
|
|
methods: {
|
|
getGoodsList() {
|
|
vk.callFunction({
|
|
url: 'client/enquiry/template/pub/getList',
|
|
pageSize: 500,
|
|
title: '请求中',
|
|
success: ({rows}) => {
|
|
this.goodsList = rows
|
|
}
|
|
})
|
|
},
|
|
selectGoods(val) {
|
|
this.form1.data.model = []
|
|
this.goodsList.forEach(({_id, name, extraAttributes}) => {
|
|
if (_id === val) {
|
|
this.form1.data.goodsName = name
|
|
this.goodsAttributes = extraAttributes
|
|
this.goodsAttributes.forEach(attr => {
|
|
if (attr.label) this.form1.data.model.push({
|
|
label: attr.label,
|
|
value: null
|
|
})
|
|
})
|
|
}
|
|
})
|
|
},
|
|
selectProvince(index) {
|
|
this.form1.data.addressRegion[0] = this.provinceData[index].code
|
|
},
|
|
selectCity(index) {
|
|
this.form1.data.addressRegion[1] = this.cityData[this.provinceIndex][index].code
|
|
},
|
|
selectArea(index) {
|
|
this.form1.data.addressRegion[2] = this.areaData[this.provinceIndex][this.cityIndex][index].code
|
|
},
|
|
|
|
},
|
|
watch: {
|
|
"form1.data": {
|
|
immediate: true,
|
|
handler(val) {
|
|
this.$emit('input', val)
|
|
console.log("this.$emit('input', val.data)");
|
|
}
|
|
},
|
|
value: {
|
|
immediate: true,
|
|
handler(val) {
|
|
this.form1.data = val
|
|
console.log("this.form1.data = val", val);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.product-title {
|
|
margin: 10px;
|
|
text-align: center;
|
|
font-size: 14px;
|
|
}
|
|
</style>
|
|
|
|
<style>
|
|
::v-deep .input-with-select .el-input-group__append {
|
|
background-color: #fff !important;
|
|
width: 130px !important;
|
|
}
|
|
</style> |