Commit da0ae5d8 by liimin

完善组件

1 parent 44a94b84
......@@ -59,10 +59,10 @@
>
<gl-form-item label='选择用户:'>
<gl-select
v-model="model.user"
v-model="result.influenceScope"
placeholder="请选择用户"
style="width:100%"
name="user"
name="influenceScope"
data-vv-as="用户"
v-validate="'required'"
>
......@@ -74,16 +74,16 @@
/>
</gl-select>
<span
v-show="errorBags && errorBags.has('user')"
v-show="errorBags && errorBags.has('influenceScope')"
class="error"
>
{{ errorBags && errorBags.first('user') }}
{{ errorBags && errorBags.first('influenceScope') }}
</span>
</gl-form-item>
</gl-col>
<gl-col
:span="24"
v-if="!manufactureOnly && model.user==='LIST'"
v-if="!manufactureOnly && result.influenceScope==='LIST'"
>
<gl-form-item label='灰度用户:'>
<gl-upload
......@@ -96,6 +96,7 @@
name="grayscaleUserList"
data-vv-as="灰度用户"
v-validate="'required'"
:file-list="model.file_list"
multiple
>
<gl-button
......@@ -136,7 +137,8 @@ export default {
width: String,
manufactureOnly: Boolean,
in_row: Boolean,
uploadAction: String
uploadAction: String,
default_value: Object
// errorBags: Object
},
watch: {
......@@ -179,37 +181,50 @@ export default {
{ label: '指定用户(灰度)', value: 'LIST' }
],
model: {
user: '',
merchantId: '',
manufacturerId: ''
manufacturerId: '',
file_list: [] //文件列表
},
result: {
manufacturers: null,
merchants: null,
grayscaleUserList: null
manufacturers: null, //生产厂商
merchants: null, //商户渠道
grayscaleUserList: null, //灰度用户列表
influenceScope: '' //用户类型
}
}
},
methods: {
get_manufacturer_list() {
if (manufacturer_list_back_up.length) {
this.manufacturer_list = manufacturer_list_back_up
return
}
manufacturers
.req({})
.then(res => (manufacturer_list_back_up = this.manufacturer_list = res))
.catch(err => this.error(err))
return new Promise((resolve, reject) => {
if (manufacturer_list_back_up.length) {
// this.manufacturer_list = manufacturer_list_back_up
resolve(manufacturer_list_back_up)
}
manufacturers
.req({})
.then(res =>
// manufacturer_list_back_up = this.manufacturer_list = res
// this.model.manufacturerId = this.default_value.manufacturerId
resolve(res)
)
.catch(err => reject(err))
})
},
get_merchant_list() {
if (merchant_list_back_up.length) {
this.merchant_list = merchant_list_back_up
return
}
merchants
.req({ merchantType: 401, merchantStatus: 0 })
.then(res => (merchant_list_back_up = this.merchant_list = res))
.catch(err => this.error(err))
return new Promise((resolve, reject) => {
if (merchant_list_back_up.length) {
// this.merchant_list = merchant_list_back_up
resolve(merchant_list_back_up)
}
merchants
.req({ merchantType: 401, merchantStatus: 0 })
.then(
res => resolve(res)
// merchant_list_back_up = this.merchant_list = res
// this.model.merchantId = this.default_value.merchantId
)
.catch(err => reject(err))
})
},
// 上传灰度用户成功后调接口解析Excel
success_grayscaleuser(res) {
......@@ -237,9 +252,26 @@ export default {
this.model.grayscaleUserList = ''
}
},
mounted() {
this.get_manufacturer_list()
this.get_merchant_list()
created() {
if (this.default_value) {
this.model.merchantId = this.default_value.merchantId
this.model.manufacturerId = this.default_value.manufacturerId
this.result.influenceScope = this.default_value.influenceScope
this.model.file_list = this.default_value.file_list
this.result.grayscaleUserList = this.default_value.grayscaleuser
/**
* file_list
* [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]
*/
}
Promise.all([this.get_manufacturer_list(), this.get_merchant_list()]).then(
result => {
manufacturer_list_back_up = this.manufacturer_list = result[0]
this.model.manufacturerId = this.default_value.manufacturerId
merchant_list_back_up = this.merchant_list = result[1]
this.model.merchantId = this.default_value.merchantId
}
)
}
}
</script>
......
......@@ -41,6 +41,7 @@
:in_row='true'
:value.sync="editForm.manufacturer"
:uploadAction="uploadAction"
:default_value="default_value"
/>
<!-- </gl-form-item> -->
</gl-col>
......@@ -295,6 +296,13 @@ export default {
children: 'children',
label: 'label'
},
default_value: {
// merchantId: 19180001,
manufacturerId: 10012,
file_list: [{ name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg' }],
influenceScope: 'LIST',
grayscaleuser: ['11']
},
triModel: {
pop: false,
dialog: true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!