文件
mashangyoujiu/Public/Retail/js/select-cashier.js

89 行
2.4 KiB
JavaScript
可执行文件

/**
* 选择收银员
*/
Vue.component('select-cashier', {
template: `<el-select v-model="cashier_id"
:placeholder="placeholder"
:disabled="isDisabled"
:size="size"
clearable
filterable>
<el-option v-for="item in dataList"
:value-key="item.id"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>`,
props: {
'cashierId': {
type: String,
default: '',
},//选择的收银员ID
'isDisabled': {
type: Boolean,
default: false,
},//是否禁止修改
'placeholder': {
type: String,
default: '选择收银员'
},
'size': {
type: String,
default: 'small',
},
'storeId': {
type: String,
default: '',
},//现在门店ID
},
data() {
return {
cashier_id: '',//已选中收银员ID
dataList: [],// 数据
};
},
methods: {
//切换收银员
changeCashier() {
this.$emit('update:cashierId', this.cashier_id);
this.$emit('change', this.cashier_id);
},
//获取收银员列表
getCashierList() {
this.dataList = [];
$.ajax({
url: '/index.php/Retail/Cashier/getChooseCashierList',
type: "post",
data: {
store_id: this.storeId
},
success: (res) => {
if (res.status == 1) {
this.dataList = res.data;
}
},
})
},
},
created() {
this.cashier_id = this.cashierId;
this.getCashierList();
},
watch: {
cashierId(n) {
this.cashier_id = n;
},
cashier_id(n, o) {
if (n != o) {
this.changeCashier()
}
},
storeId(n, o) {
if (n != o) {
this.cashier_id = '';
if(n) this.getCashierList();
}
}
}
});