Files
jjx-web-sign-only/pages/enquiry/components/template.vue
T
2023-11-07 17:11:57 +08:00

184 lines
4.3 KiB
Vue

<template>
<view>
<!-- <view class="product-title">{{title}}</view> -->
<vk-data-form ref="form1" v-model="form1.data" :action="form1.props.action" :columns="form1.props.columns"
:rules="form1.props.rules" :form-type="form1.props.formType" :loading.sync="form1.props.loading"
:before-action="form1.props.beforeAction" :auto-close="true" label-width="140px" :footer-show="false"
@success="onFormSuccess">
</vk-data-form>
</view>
</template>
<script>
import Vue from 'vue'
export default {
props: {
value: {
type: Object,
default: () => {
return {}
}
},
baseAttributes: {
type: Array,
default: () => {
return []
}
},
productIndex: {
type: Number,
default: 0
}
},
data() {
return {
title: '商品',
// 表单相关开始-----------------------------------------------------------
form1: {
// 表单请求数据,此处可以设置默认值
data: {
extraAttributes: {},
attributes: {},
},
// 表单属性
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: "_id",
label: "name"
},
watch: (res) => {
const {
option
} = res
this.form1.props.columns[2].columns = option.extraAttributes.map((item, index) => {
return {
key: index,
title: item.lable,
type: "select",
data: item.values.map(citem => {
return {
value: JSON.stringify({keyName: item.lable,keyValue: citem}),
label: citem
}
})
}
})
}
},
{
key: "extraAttributes",
title: "额外属性",
type: "object",
justify: "start",
showLabel: false,
columns: [
],
},
{
key: "attributes",
title: "固定属性",
type: "object",
// justify: "start",
showLabel: false,
columns: [
],
},
{
key: "",title: "",type: 'group',showLabel: false, justify: "start",columns:
[
{key: "procureNumber", title: "采购数量", type: "number",},
{
key: "procureUnit",
title: "单位",
type: "remote-select",
showAll: true,
action: "client/enquiry/attributes/pub/getOne",
actionData: {
label: '单位',
},
},
]
},
{key: "deliveryTime", title: "交货时限", type: "date",},
{
key: "address",
title: "交货地点",
type: "object",
// justify: "start",
showLabel: false,
columns: [
{key: "region", title: "交货地点", type: "address",},
{key: "detail", title: "详细交货地址", type: "textarea",},
],
},
],
// 表单验证规则
rules: {
name:[
{ 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)
},
methods: {
},
watch: {
"form1.data"(val){
this.$emit('input', val)
console.log("this.$emit('input', val.data)");
},
value(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>