|
|
@@ -35,21 +35,24 @@
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
|
|
|
- <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="广告主名称">
|
|
|
- <a-select @change="handleChange" optionFilterProp="children" showSearch :filterOption="filterOption"
|
|
|
- v-decorator="['advertiserId', validatorRules.advertiserId]" placeholder="请选择广告主"
|
|
|
- disabled>
|
|
|
- <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
|
|
|
- {{ item.name }}
|
|
|
- </a-select-option>
|
|
|
+ <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="广告主名称">
|
|
|
+ <a-select @change="handleChange" showSearch :filterOption="false"
|
|
|
+ @search="searchAdvertiser"
|
|
|
+ @focus="loadAdvertisers"
|
|
|
+ v-decorator="['advertiserId', validatorRules.advertiserId]" placeholder="请选择广告主"
|
|
|
+ disabled>
|
|
|
+ <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
|
|
|
+ {{ item.name }}
|
|
|
+ </a-select-option>
|
|
|
</a-select>
|
|
|
- </a-form-item>
|
|
|
- <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="产品名称">
|
|
|
- <a-select optionFilterProp="children" showSearch :filterOption="filterOption"
|
|
|
- v-decorator="['productId']"
|
|
|
- placeholder="请选择产品" disabled>
|
|
|
- <a-select-option :value="item.id" v-for="(item, index) of listProduct" :key="index">
|
|
|
- {{ item.productName }}
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="产品名称">
|
|
|
+ <a-select showSearch :filterOption="false"
|
|
|
+ @search="searchProduct"
|
|
|
+ v-decorator="['productId']"
|
|
|
+ placeholder="请选择产品" disabled>
|
|
|
+ <a-select-option :value="item.id" v-for="(item, index) of listProduct" :key="index">
|
|
|
+ {{ item.productName }}
|
|
|
</a-select-option>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
@@ -476,16 +479,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
...mapGetters(['nickname', 'avatar', 'userInfo']),
|
|
|
- onChange(e) {
|
|
|
- console.log(`checked = ${e.target.value}`)
|
|
|
- },
|
|
|
- handleChange(value) {
|
|
|
- getAction('/ctop/product/list', {advertiserId: value, pageSize: 1000}).then((res) => {
|
|
|
- if (res.success) {
|
|
|
- this.listProduct = res.result.records
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
+ onChange(e) {
|
|
|
+ console.log(`checked = ${e.target.value}`)
|
|
|
+ },
|
|
|
+ handleChange(value) {
|
|
|
+ this.loadProducts(value)
|
|
|
+ },
|
|
|
handleBlur() {
|
|
|
},
|
|
|
handleFocus() {
|
|
|
@@ -493,22 +492,61 @@ export default {
|
|
|
filterOption(input, option) {
|
|
|
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
|
},
|
|
|
- getList() {
|
|
|
- var params = {}
|
|
|
- params.userId = this.userInfo().id
|
|
|
- params.pageSize = 1000
|
|
|
- params.pageNo = 1
|
|
|
- getAction(this.url.getList, params)
|
|
|
- .then((res) => {
|
|
|
- if (res.success) {
|
|
|
- this.list = res.result.records
|
|
|
- } else {
|
|
|
- this.$message.warning(res.message)
|
|
|
- }
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
+ loadAdvertisers(name = '', currentOption = null) {
|
|
|
+ const params = {
|
|
|
+ userId: this.userInfo().id,
|
|
|
+ pageSize: 50,
|
|
|
+ pageNo: 1
|
|
|
+ }
|
|
|
+ if (name) {
|
|
|
+ params.name = name
|
|
|
+ }
|
|
|
+ getAction(this.url.getList, params)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ const records = res.result.records || []
|
|
|
+ if (currentOption && currentOption.id && !records.find(item => item.id === currentOption.id)) {
|
|
|
+ this.list = [currentOption, ...records]
|
|
|
+ } else {
|
|
|
+ this.list = records
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.warning(res.message)
|
|
|
+ }
|
|
|
})
|
|
|
- },
|
|
|
+ .finally(() => {
|
|
|
+ })
|
|
|
+ },
|
|
|
+ searchAdvertiser(value) {
|
|
|
+ this.loadAdvertisers(value ? value.trim() : '')
|
|
|
+ },
|
|
|
+ loadProducts(advertiserId, productName = '', currentOption = null) {
|
|
|
+ if (!advertiserId) {
|
|
|
+ this.listProduct = []
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const params = {
|
|
|
+ advertiserId,
|
|
|
+ pageSize: 50,
|
|
|
+ pageNo: 1
|
|
|
+ }
|
|
|
+ if (productName) {
|
|
|
+ params.productName = productName
|
|
|
+ }
|
|
|
+ getAction('/ctop/product/list', params).then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ const records = res.result.records || []
|
|
|
+ if (currentOption && currentOption.id && !records.find(item => item.id === currentOption.id)) {
|
|
|
+ this.listProduct = [currentOption, ...records]
|
|
|
+ } else {
|
|
|
+ this.listProduct = records
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ searchProduct(value) {
|
|
|
+ this.loadProducts(this.getFormFieldValue('advertiserId'), value ? value.trim() : '')
|
|
|
+ },
|
|
|
getAgentCodeList() {
|
|
|
// /agent/agentConfig/list
|
|
|
getAction('/agent/agentConfig/list').then((res) => {
|
|
|
@@ -530,27 +568,29 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- add(item) {
|
|
|
- this.editAll = false
|
|
|
- this.edit({
|
|
|
- responsibleId: this.userInfo().id, //用户Id
|
|
|
- mediaId: '2',
|
|
|
- ...item,
|
|
|
- })
|
|
|
- },
|
|
|
- edit(record) {
|
|
|
- console.log(record)
|
|
|
- this.getSupplierList()
|
|
|
- this.getList()
|
|
|
-
|
|
|
- if (record.advertiserId) {
|
|
|
- this.editAll = true
|
|
|
- getAction('/ctop/product/list', {advertiserId: record.advertiserId, pageSize: 1000}).then((res) => {
|
|
|
- if (res.success) {
|
|
|
- this.listProduct = res.result.records
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ add(item = {}) {
|
|
|
+ this.editAll = false
|
|
|
+ this.edit({
|
|
|
+ responsibleId: this.userInfo().id, //用户Id
|
|
|
+ mediaId: '2',
|
|
|
+ ...item,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ edit(record = {}) {
|
|
|
+ console.log(record)
|
|
|
+ this.getSupplierList()
|
|
|
+ this.loadAdvertisers('', record.advertiserId ? {
|
|
|
+ id: record.advertiserId,
|
|
|
+ name: record.advertiserId_dictText
|
|
|
+ } : null)
|
|
|
+
|
|
|
+ if (record.advertiserId) {
|
|
|
+ this.editAll = true
|
|
|
+ this.loadProducts(record.advertiserId, '', record.productId ? {
|
|
|
+ id: record.productId,
|
|
|
+ productName: record.productId_dictText
|
|
|
+ } : null)
|
|
|
+ }
|
|
|
// else if (this.request == '2,4') {
|
|
|
// params.type = 'kuaishou'
|
|
|
// }
|
|
|
@@ -871,4 +911,4 @@ export default {
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style lang="less" scoped></style>
|
|
|
+<style lang="less" scoped></style>
|