|
@@ -50,7 +50,7 @@
|
|
<a-form-model-item label="基本单位" prop="unit">
|
|
<a-form-model-item label="基本单位" prop="unit">
|
|
<a-input-group compact>
|
|
<a-input-group compact>
|
|
<a-input
|
|
<a-input
|
|
- style="width: 80%"
|
|
|
|
|
|
+ style="width: 70%"
|
|
v-model.trim="form.unit"
|
|
v-model.trim="form.unit"
|
|
id="productInfoEdit-unit-input"
|
|
id="productInfoEdit-unit-input"
|
|
placeholder="请输入基本单位"
|
|
placeholder="请输入基本单位"
|
|
@@ -58,7 +58,7 @@
|
|
@keydown.enter.native="nextFocus('unit', 'UNIT', $event, 'vSelect')"
|
|
@keydown.enter.native="nextFocus('unit', 'UNIT', $event, 'vSelect')"
|
|
allowClear/>
|
|
allowClear/>
|
|
<v-select
|
|
<v-select
|
|
- style="width: 20%"
|
|
|
|
|
|
+ style="width: 30%"
|
|
code="UNIT"
|
|
code="UNIT"
|
|
@change="unitChange"
|
|
@change="unitChange"
|
|
id="productInfoEdit-unit"
|
|
id="productInfoEdit-unit"
|
|
@@ -69,14 +69,14 @@
|
|
</a-form-model-item>
|
|
</a-form-model-item>
|
|
<a-form-model-item label="产品品牌" prop="productBrandSn">
|
|
<a-form-model-item label="产品品牌" prop="productBrandSn">
|
|
<a-select
|
|
<a-select
|
|
- show-search
|
|
|
|
|
|
+ :showSearch="true"
|
|
id="productInfoEdit-productBrand"
|
|
id="productInfoEdit-productBrand"
|
|
v-model="form.productBrandSn"
|
|
v-model="form.productBrandSn"
|
|
- placeholder="请输入名称或拼音查询,如果没有请点击 '+' 新增"
|
|
|
|
|
|
+ placeholder="请输入名称搜索,如果没有请点击 '+' 新增"
|
|
:disabled="isEdit"
|
|
:disabled="isEdit"
|
|
- :filter-option="false"
|
|
|
|
- :not-found-content="fetching ? undefined : null"
|
|
|
|
- @search="fetchUser"
|
|
|
|
|
|
+ :filter-option="filterOption"
|
|
|
|
+ option-filter-prop="children"
|
|
|
|
+ allowClear
|
|
style="width: 90%;"
|
|
style="width: 90%;"
|
|
ref="productBrandSn"
|
|
ref="productBrandSn"
|
|
@keydown.enter.native="nextFocus('productBrandSn', 'productType', $event)"
|
|
@keydown.enter.native="nextFocus('productBrandSn', 'productType', $event)"
|
|
@@ -294,25 +294,31 @@ export default {
|
|
this.$refs.ruleForm.clearValidate('warehouse')
|
|
this.$refs.ruleForm.clearValidate('warehouse')
|
|
},
|
|
},
|
|
// 搜索品牌
|
|
// 搜索品牌
|
|
- fetchUser (value) {
|
|
|
|
|
|
+ searchBrand (value, defval) {
|
|
console.log('fetching user', value)
|
|
console.log('fetching user', value)
|
|
this.fetching = true
|
|
this.fetching = true
|
|
dealerProductBrandQuery({ 'queryWord': value }).then(res => {
|
|
dealerProductBrandQuery({ 'queryWord': value }).then(res => {
|
|
if (res.status == 200) {
|
|
if (res.status == 200) {
|
|
this.productBrandList = res.data || []
|
|
this.productBrandList = res.data || []
|
|
this.fetching = false
|
|
this.fetching = false
|
|
|
|
+ // 默认值
|
|
|
|
+ if (defval) {
|
|
|
|
+ const row = this.productBrandList.find(item => item.brandName == defval)
|
|
|
|
+ this.form.productBrandSn = row.brandSn
|
|
|
|
+ this.$refs.ruleForm.clearValidate('productBrandSn')
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
this.productBrandList = []
|
|
this.productBrandList = []
|
|
this.fetching = false
|
|
this.fetching = false
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- filterEmpty () {
|
|
|
|
- let str = this.form.name
|
|
|
|
- str = str.replace(/\ +/g, '')
|
|
|
|
- str = str.replace(/[ ]/g, '')
|
|
|
|
- str = str.replace(/[\r\n]/g, '')
|
|
|
|
- this.form.name = str
|
|
|
|
|
|
+ filterOption (input, option) {
|
|
|
|
+ console.log(input, option.data.attrs.pinyin)
|
|
|
|
+ return (
|
|
|
|
+ option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
|
|
|
|
+ option.data.attrs.pinyin && option.data.attrs.pinyin.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
|
|
+ )
|
|
},
|
|
},
|
|
// 选择单位
|
|
// 选择单位
|
|
unitChange (a, b) {
|
|
unitChange (a, b) {
|
|
@@ -328,7 +334,7 @@ export default {
|
|
const productTypeSn3 = res.data.productTypeSn3 ? res.data.productTypeSn3 : ''
|
|
const productTypeSn3 = res.data.productTypeSn3 ? res.data.productTypeSn3 : ''
|
|
this.form.productType = [productTypeSn1, productTypeSn2, productTypeSn3]
|
|
this.form.productType = [productTypeSn1, productTypeSn2, productTypeSn3]
|
|
if (res.data.productBrandName) {
|
|
if (res.data.productBrandName) {
|
|
- this.fetchUser(res.data.productBrandName)
|
|
|
|
|
|
+ this.searchBrand(res.data.productBrandName)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
this.$refs.ruleForm.resetFields()
|
|
this.$refs.ruleForm.resetFields()
|
|
@@ -392,14 +398,10 @@ export default {
|
|
this.form.productTypeSn3 = val[2] ? val[2] : ''
|
|
this.form.productTypeSn3 = val[2] ? val[2] : ''
|
|
},
|
|
},
|
|
// 新增品牌 成功
|
|
// 新增品牌 成功
|
|
- handleOk () {
|
|
|
|
- // 获取品牌数据列表,并赋值
|
|
|
|
- this.getProductBrand('val')
|
|
|
|
- },
|
|
|
|
- filterOption (input, option) {
|
|
|
|
- return (
|
|
|
|
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
|
|
- )
|
|
|
|
|
|
+ handleOk (val) {
|
|
|
|
+ if (val) { // 需将新增加的品牌回填到产品品牌的地方,即不需要用户再选一下
|
|
|
|
+ this.searchBrand('', val)
|
|
|
|
+ }
|
|
},
|
|
},
|
|
// 返回
|
|
// 返回
|
|
handleBack () {
|
|
handleBack () {
|
|
@@ -409,18 +411,6 @@ export default {
|
|
this.$emit('cansel')
|
|
this.$emit('cansel')
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- // 产品品牌 列表
|
|
|
|
- getProductBrand (val) {
|
|
|
|
- dealerProductBrandQuery({}).then(res => {
|
|
|
|
- if (res.status == 200) {
|
|
|
|
- this.productBrandList = res.data
|
|
|
|
- if (val) { // 需将新增加的品牌回填到产品品牌的地方,即不需要用户再选一下
|
|
|
|
- this.form.productBrandSn = this.productBrandList[0].brandSn
|
|
|
|
- this.$refs.ruleForm.clearValidate('productBrandSn')
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
// 产品分类 列表
|
|
// 产品分类 列表
|
|
getProductType () {
|
|
getProductType () {
|
|
dealerProductTypeList({}).then(res => {
|
|
dealerProductTypeList({}).then(res => {
|
|
@@ -432,25 +422,25 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
pageInit () {
|
|
pageInit () {
|
|
- this.getProductType()
|
|
|
|
this.$refs.ruleForm.resetFields()
|
|
this.$refs.ruleForm.resetFields()
|
|
- // 默认首项获取焦点
|
|
|
|
- const _this = this
|
|
|
|
- setTimeout(() => {
|
|
|
|
- if (_this.$refs['name']) {
|
|
|
|
- _this.$refs['name'].focus()
|
|
|
|
- }
|
|
|
|
- }, 300)
|
|
|
|
- if (this.$route.params.id) { // 编辑页
|
|
|
|
|
|
+ this.getProductType()
|
|
|
|
+ this.searchBrand('')
|
|
|
|
+
|
|
|
|
+ // 编辑页
|
|
|
|
+ if (this.$route.params.id && this.pageType == 'pages') {
|
|
this.getGoodsDetail()
|
|
this.getGoodsDetail()
|
|
}
|
|
}
|
|
- // 如果是其它页面新建产品
|
|
|
|
- if (this.pageType == 'modal') {
|
|
|
|
- this.form = Object.assign(this.form, this.formData)
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
|
|
+
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ // 默认首项获取焦点
|
|
|
|
+ this.$refs['name'].focus()
|
|
|
|
+ // 如果是其它页面新建产品
|
|
|
|
+ if (this.pageType == 'modal') {
|
|
|
|
+ console.log(this.paramsData)
|
|
|
|
+ this.form = Object.assign(this.form, this.paramsData)
|
|
this.$refs.warehouse.setDefaultVal()
|
|
this.$refs.warehouse.setDefaultVal()
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted () {
|
|
mounted () {
|