|
|
@ -20,26 +20,6 @@ |
|
|
<span style="color: #f56c6c">当前账号无 Customer 权限</span> |
|
|
<span style="color: #f56c6c">当前账号无 Customer 权限</span> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
</el-form> |
|
|
|
|
|
|
|
|
<el-dialog |
|
|
|
|
|
title="选择 Customer" |
|
|
|
|
|
:visible.sync="forceDialogVisible" |
|
|
|
|
|
width="420px" |
|
|
|
|
|
:close-on-click-modal="false" |
|
|
|
|
|
:show-close="false" |
|
|
|
|
|
append-to-body> |
|
|
|
|
|
<p style="margin-bottom: 12px">请先选择本次会话要操作的 Customer:</p> |
|
|
|
|
|
<el-select v-model="dialogCustomer" filterable placeholder="请选择" style="width: 100%"> |
|
|
|
|
|
<el-option |
|
|
|
|
|
v-for="item in options" |
|
|
|
|
|
:key="item.code" |
|
|
|
|
|
:label="formatLabel(item)" |
|
|
|
|
|
:value="item.code" /> |
|
|
|
|
|
</el-select> |
|
|
|
|
|
<span slot="footer"> |
|
|
|
|
|
<el-button type="primary" :disabled="!dialogCustomer" @click="confirmDialog">确定</el-button> |
|
|
|
|
|
</span> |
|
|
|
|
|
</el-dialog> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
@ -56,14 +36,18 @@ export default { |
|
|
data () { |
|
|
data () { |
|
|
return { |
|
|
return { |
|
|
options: [], |
|
|
options: [], |
|
|
innerCustomer: this.value, |
|
|
|
|
|
forceDialogVisible: false, |
|
|
|
|
|
dialogCustomer: '' |
|
|
|
|
|
|
|
|
innerCustomer: this.value |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
|
value (val) { |
|
|
value (val) { |
|
|
this.innerCustomer = val |
|
|
this.innerCustomer = val |
|
|
|
|
|
if (!val) { |
|
|
|
|
|
this.ensureDefaultCustomer() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
site () { |
|
|
|
|
|
this.loadOptions() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted () { |
|
|
mounted () { |
|
|
@ -79,12 +63,7 @@ export default { |
|
|
return getPoCustomerScope({ site: this.site }).then(({ data }) => { |
|
|
return getPoCustomerScope({ site: this.site }).then(({ data }) => { |
|
|
if (data && data.code === 0) { |
|
|
if (data && data.code === 0) { |
|
|
this.options = data.data || [] |
|
|
this.options = data.data || [] |
|
|
if (this.options.length === 1) { |
|
|
|
|
|
this.selectCustomer(this.options[0].code) |
|
|
|
|
|
} else if (this.options.length > 1 && !this.innerCustomer) { |
|
|
|
|
|
this.forceDialogVisible = true |
|
|
|
|
|
this.dialogCustomer = '' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.ensureDefaultCustomer() |
|
|
} else { |
|
|
} else { |
|
|
this.options = [] |
|
|
this.options = [] |
|
|
this.$message.error((data && data.msg) || '加载 Customer 权限失败') |
|
|
this.$message.error((data && data.msg) || '加载 Customer 权限失败') |
|
|
@ -94,6 +73,18 @@ export default { |
|
|
this.$message.error('加载 Customer 权限失败') |
|
|
this.$message.error('加载 Customer 权限失败') |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
ensureDefaultCustomer () { |
|
|
|
|
|
if (!Array.isArray(this.options) || this.options.length === 0) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (this.innerCustomer) { |
|
|
|
|
|
const exists = this.options.some(item => item && item.code === this.innerCustomer) |
|
|
|
|
|
if (exists) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.selectCustomer(this.options[0].code) |
|
|
|
|
|
}, |
|
|
selectCustomer (code) { |
|
|
selectCustomer (code) { |
|
|
const option = this.options.find(item => item.code === code) || null |
|
|
const option = this.options.find(item => item.code === code) || null |
|
|
this.innerCustomer = code |
|
|
this.innerCustomer = code |
|
|
@ -104,11 +95,6 @@ export default { |
|
|
const option = this.options.find(item => item.code === code) || null |
|
|
const option = this.options.find(item => item.code === code) || null |
|
|
this.$emit('input', code) |
|
|
this.$emit('input', code) |
|
|
this.$emit('change', code, option) |
|
|
this.$emit('change', code, option) |
|
|
}, |
|
|
|
|
|
confirmDialog () { |
|
|
|
|
|
if (!this.dialogCustomer) return |
|
|
|
|
|
this.forceDialogVisible = false |
|
|
|
|
|
this.selectCustomer(this.dialogCustomer) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|