feat: 添加下拉远程搜索并完善登录会话

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-04 15:57:46 +08:00
co-authored by Cursor
parent e785a99b7d
commit 55f13bb47b
41 changed files with 1734 additions and 330 deletions
@@ -122,7 +122,7 @@
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
<FabricInfoPopup :show.sync="fabricInfoShow" :data="currentFabricInfo" />
@@ -51,7 +51,7 @@
<FabricOutFooter :buttons="statusActionButtons" @action="handleStatusAction" />
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
<FabricInfoPopup :show.sync="fabricInfoShow" :data="currentFabricInfo" />
<FineCodePopup :show.sync="fineCodeShow" :list="currentFineCodes" :readonly="false" @delete="onDeleteFineCode" />
</view>
@@ -59,7 +59,7 @@
</u-popup>
<u-select v-model="statusSelectShow" :list="statusSelectList" @confirm="onStatusConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" @confirm="onUnitConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" remote :loading="selectSearching" @search="onUnitSearch" @confirm="onUnitConfirm"></u-select>
</view>
</template>
@@ -75,6 +75,7 @@ import {
mapToSelectOptions,
fetchAllOrderList,
} from '@/common/storeFabricBusinessOut';
import { withNameParam } from '@/common/remoteSelect';
export default {
components: { addBtn, FabricOutItem },
@@ -90,6 +91,9 @@ export default {
deliveryUnitOptions: [],
businessUnitOptions: [],
unitOptionsLoading: false,
selectSearching: false,
unitSearchSeq: 0,
unitSelectList: [{ value: '', label: '全部' }],
billTypeName: (BILL_TYPES[0] || {}).label || '坯布其他出货单',
filters: {
order_no: '',
@@ -118,10 +122,6 @@ export default {
businessUnitLabel() {
return this.filters.business_unit_name || '';
},
unitSelectList() {
const options = this.unitSelectType === 'delivery' ? this.deliveryUnitOptions : this.businessUnitOptions;
return [{ value: '', label: '全部' }, ...options];
},
},
onLoad() {
uni.setNavigationBarTitle({ title: '坯布出库列表' });
@@ -160,21 +160,40 @@ export default {
return this.businessUnitOptions;
});
},
applyUnitSelectList(list) {
const rows = Array.isArray(list) ? list.slice() : [];
this.unitSelectList = [{ value: '', label: '全部' }].concat(rows);
},
openUnitSelect(type) {
if (this.unitOptionsLoading) return;
this.unitOptionsLoading = true;
const loadFn = type === 'delivery' ? this.loadDeliveryUnitOptions : this.loadBusinessUnitOptions;
loadFn.call(this)
.then((list) => {
if (!list.length) {
uni.showToast({ title: '暂无可选单位', icon: 'none' });
return;
this.unitSelectType = type;
const cache = type === 'delivery' ? this.deliveryUnitOptions : this.businessUnitOptions;
this.applyUnitSelectList(cache);
this.unitSelectShow = true;
},
onUnitSearch(keyword) {
const seq = ++this.unitSearchSeq;
const isDelivery = this.unitSelectType === 'delivery';
const empty = !String(keyword || '').trim();
this.selectSearching = true;
const params = isDelivery ? {} : { unit_type_id: BUSINESS_UNIT_TYPE_DYE_FACTORY };
this.$u.api.businessUnit.list(withNameParam(params, keyword))
.then((res) => {
if (seq !== this.unitSearchSeq) return;
const list = mapToSelectOptions(res);
if (empty) {
if (isDelivery) this.deliveryUnitOptions = list;
else this.businessUnitOptions = list;
}
this.unitSelectType = type;
this.unitSelectShow = true;
this.applyUnitSelectList(list);
})
.finally(() => {
this.unitOptionsLoading = false;
.catch((e) => {
if (seq !== this.unitSearchSeq) return;
uni.showToast({ title: (e && e.message) || '搜索失败', icon: 'none' });
})
.then(() => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
}, () => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
});
},
openDeliveryUnitSelect() {
@@ -10,6 +10,8 @@
*/
import util from '@/common/util';
import scanMixin from '@/common/scanMixin.js';
import remoteSelectMixin from '@/common/remoteSelectMixin.js';
import { withNameParam } from '@/common/remoteSelect';
import { initTts, speak } from '@/common/tts.js';
import {
AUDIT_STATUS_MAP,
@@ -36,7 +38,7 @@ import {
} from '@/common/storeFabricBusinessOut';
export default {
mixins: [scanMixin],
mixins: [scanMixin, remoteSelectMixin],
data() {
return {
pageMode: 'add',
@@ -145,6 +147,15 @@ export default {
return this.businessUnitOptions;
});
},
fetchRemoteSelectOptions(type, keyword) {
if (type !== '染厂') return Promise.resolve([]);
return this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_DYE_FACTORY }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (!String(keyword || '').trim()) this.businessUnitOptions = list;
return list;
});
},
getEmptyForm() {
return {
order_no: '',
@@ -185,19 +196,9 @@ export default {
},
pickerSelectFun(type) {
if (!this.headerEditable) return;
this.selectType = type;
const openPicker = (list) => {
if (!list.length) {
this.showError('暂无可选数据');
return;
}
this.selectList = list;
this.selectShow = true;
};
if (type === '染厂') {
this.ensureBusinessUnitOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载单位列表失败'));
this.openSelectPicker(type, this.businessUnitOptions);
return;
}
},
selectConfirmFun(e) {
@@ -107,7 +107,7 @@
@action="handleStatusAction"
/>
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
</view>
</template>
@@ -85,7 +85,7 @@
<FabricOutFooter :buttons="statusActionButtons" @action="handleStatusAction" />
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
</view>
</template>
@@ -47,7 +47,7 @@
</u-popup>
<u-select v-model="statusSelectShow" :list="statusSelectList" @confirm="onStatusConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" @confirm="onUnitConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" remote :loading="selectSearching" @search="onUnitSearch" @confirm="onUnitConfirm"></u-select>
</view>
</template>
@@ -63,6 +63,7 @@ import {
mapToSelectOptions,
fetchAllOrderList,
} from '@/common/storeGoodsProcessIn';
import { withNameParam } from '@/common/remoteSelect';
export default {
components: { addBtn, ProcessInItem },
@@ -79,6 +80,9 @@ export default {
processUnitOptions: [],
warehouseOptions: [],
unitOptionsLoading: false,
selectSearching: false,
unitSearchSeq: 0,
unitSelectList: [{ value: '', label: '全部' }],
filters: {
order_no: '',
process_unit_id: '',
@@ -104,10 +108,6 @@ export default {
warehouseLabel() {
return this.filters.warehouse_name || '';
},
unitSelectList() {
const options = this.unitSelectType === 'warehouse' ? this.warehouseOptions : this.processUnitOptions;
return [{ value: '', label: '全部' }, ...options];
},
},
onLoad() {
uni.setNavigationBarTitle({ title: '加工进仓列表' });
@@ -145,22 +145,40 @@ export default {
return this.warehouseOptions;
});
},
applyUnitSelectList(list) {
const rows = Array.isArray(list) ? list.slice() : [];
this.unitSelectList = [{ value: '', label: '全部' }].concat(rows);
},
openUnitSelect(type) {
if (this.unitOptionsLoading) return;
this.unitOptionsLoading = true;
const loadFn = type === 'warehouse' ? this.loadWarehouseOptions : this.loadProcessUnitOptions;
loadFn.call(this)
.then((list) => {
if (!list.length) {
uni.showToast({ title: '暂无可选数据', icon: 'none' });
return;
}
this.unitSelectType = type;
this.unitSelectShow = true;
})
.finally(() => {
this.unitOptionsLoading = false;
});
this.unitSelectType = type;
const cache = type === 'warehouse' ? this.warehouseOptions : this.processUnitOptions;
this.applyUnitSelectList(cache);
this.unitSelectShow = true;
},
onUnitSearch(keyword) {
const seq = ++this.unitSearchSeq;
const type = this.unitSelectType;
const empty = !String(keyword || '').trim();
this.selectSearching = true;
const req = type === 'warehouse'
? this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
: this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PROCESS }, keyword));
req.then((res) => {
if (seq !== this.unitSearchSeq) return;
const list = mapToSelectOptions(res);
if (empty) {
if (type === 'warehouse') this.warehouseOptions = list;
else this.processUnitOptions = list;
}
this.applyUnitSelectList(list);
}).catch((e) => {
if (seq !== this.unitSearchSeq) return;
uni.showToast({ title: (e && e.message) || '搜索失败', icon: 'none' });
}).then(() => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
}, () => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
});
},
openProcessUnitSelect() {
this.openUnitSelect('process');
@@ -8,6 +8,8 @@
*/
import util from '@/common/util';
import scanMixin from '@/common/scanMixin.js';
import remoteSelectMixin from '@/common/remoteSelectMixin.js';
import { withNameParam } from '@/common/remoteSelect';
import { initTts, speak } from '@/common/tts.js';
import {
AUDIT_STATUS_MAP,
@@ -36,7 +38,7 @@ import {
} from '@/common/storeGoodsProcessIn';
export default {
mixins: [scanMixin],
mixins: [scanMixin, remoteSelectMixin],
data() {
return {
pageMode: 'add',
@@ -309,6 +311,34 @@ export default {
return this.saleSystemOptions;
});
},
fetchRemoteSelectOptions(type, keyword) {
const empty = !String(keyword || '').trim();
if (type === '加工单位') {
return this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PROCESS }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.processUnitOptions = list;
return list;
});
}
if (type === '仓库名称') {
return this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.warehouseOptions = list;
return list;
});
}
if (type === '营销体系') {
return this.$u.api.saleSystem.getDropdownList(withNameParam({}, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.saleSystemOptions = list;
return list;
});
}
return Promise.resolve([]);
},
applyDefaultWarehouse() {
const app = getApp();
const picked = pickDefaultWarehouse(
@@ -390,30 +420,22 @@ export default {
},
pickerSelectFun(type) {
if (!this.headerEditable) return;
this.selectType = type;
const openPicker = (list) => {
if (!list.length) {
if (type === '进仓类型') {
this.selectType = type;
if (!this.inOrderTypeOptions.length) {
this.showError('暂无可选数据');
return;
}
this.selectList = list;
this.selectList = this.inOrderTypeOptions;
this.selectShow = true;
};
if (type === '进仓类型') {
openPicker(this.inOrderTypeOptions);
} else if (type === '加工单位') {
this.ensureProcessUnitOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载加工单位失败'));
} else if (type === '仓库名称') {
this.ensureWarehouseOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载仓库失败'));
} else if (type === '营销体系') {
this.ensureSaleSystemOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载营销体系失败'));
return;
}
const cache = {
'加工单位': this.processUnitOptions,
'仓库名称': this.warehouseOptions,
'营销体系': this.saleSystemOptions,
};
if (cache[type]) this.openSelectPicker(type, cache[type]);
},
selectConfirmFun(e) {
const item = e[0];
@@ -64,7 +64,7 @@
@action="handleStatusAction"
/>
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
</view>
</template>
@@ -45,7 +45,7 @@
<FabricOutFooter :buttons="statusActionButtons" @action="handleStatusAction" />
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
</view>
</template>
@@ -47,7 +47,7 @@
</u-popup>
<u-select v-model="statusSelectShow" :list="statusSelectList" @confirm="onStatusConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" @confirm="onUnitConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" remote :loading="selectSearching" @search="onUnitSearch" @confirm="onUnitConfirm"></u-select>
</view>
</template>
@@ -63,6 +63,7 @@ import {
mapToSelectOptions,
fetchAllOrderList,
} from '@/common/storeGoodsProcessOut';
import { withNameParam } from '@/common/remoteSelect';
export default {
components: { addBtn, ProcessOutItem },
@@ -79,6 +80,9 @@ export default {
processUnitOptions: [],
warehouseOptions: [],
unitOptionsLoading: false,
selectSearching: false,
unitSearchSeq: 0,
unitSelectList: [{ value: '', label: '全部' }],
filters: {
order_no: '',
process_unit_id: '',
@@ -104,10 +108,6 @@ export default {
warehouseLabel() {
return this.filters.warehouse_name || '';
},
unitSelectList() {
const options = this.unitSelectType === 'warehouse' ? this.warehouseOptions : this.processUnitOptions;
return [{ value: '', label: '全部' }, ...options];
},
},
onLoad() {
uni.setNavigationBarTitle({ title: '加工出仓列表' });
@@ -145,22 +145,40 @@ export default {
return this.warehouseOptions;
});
},
applyUnitSelectList(list) {
const rows = Array.isArray(list) ? list.slice() : [];
this.unitSelectList = [{ value: '', label: '全部' }].concat(rows);
},
openUnitSelect(type) {
if (this.unitOptionsLoading) return;
this.unitOptionsLoading = true;
const loadFn = type === 'warehouse' ? this.loadWarehouseOptions : this.loadProcessUnitOptions;
loadFn.call(this)
.then((list) => {
if (!list.length) {
uni.showToast({ title: '暂无可选数据', icon: 'none' });
return;
}
this.unitSelectType = type;
this.unitSelectShow = true;
})
.finally(() => {
this.unitOptionsLoading = false;
});
this.unitSelectType = type;
const cache = type === 'warehouse' ? this.warehouseOptions : this.processUnitOptions;
this.applyUnitSelectList(cache);
this.unitSelectShow = true;
},
onUnitSearch(keyword) {
const seq = ++this.unitSearchSeq;
const type = this.unitSelectType;
const empty = !String(keyword || '').trim();
this.selectSearching = true;
const req = type === 'warehouse'
? this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
: this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PROCESS }, keyword));
req.then((res) => {
if (seq !== this.unitSearchSeq) return;
const list = mapToSelectOptions(res);
if (empty) {
if (type === 'warehouse') this.warehouseOptions = list;
else this.processUnitOptions = list;
}
this.applyUnitSelectList(list);
}).catch((e) => {
if (seq !== this.unitSearchSeq) return;
uni.showToast({ title: (e && e.message) || '搜索失败', icon: 'none' });
}).then(() => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
}, () => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
});
},
openProcessUnitSelect() {
this.openUnitSelect('process');
@@ -7,6 +7,8 @@
*/
import util from '@/common/util';
import scanMixin from '@/common/scanMixin.js';
import remoteSelectMixin from '@/common/remoteSelectMixin.js';
import { withNameParam } from '@/common/remoteSelect';
import { initTts, speak } from '@/common/tts.js';
import {
AUDIT_STATUS_MAP,
@@ -32,7 +34,7 @@ import {
} from '@/common/storeGoodsProcessOut';
export default {
mixins: [scanMixin],
mixins: [scanMixin, remoteSelectMixin],
data() {
return {
pageMode: 'add',
@@ -211,6 +213,26 @@ export default {
return this.warehouseOptions;
});
},
fetchRemoteSelectOptions(type, keyword) {
const empty = !String(keyword || '').trim();
if (type === '加工单位') {
return this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PROCESS }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.processUnitOptions = list;
return list;
});
}
if (type === '仓库名称') {
return this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.warehouseOptions = list;
return list;
});
}
return Promise.resolve([]);
},
applyDefaultWarehouse() {
const app = getApp();
const picked = pickDefaultWarehouse(
@@ -264,28 +286,26 @@ export default {
},
pickerSelectFun(type) {
if (!this.headerEditable) return;
this.selectType = type;
const openPicker = (list) => {
if (!list.length) {
this.showError('暂无可选数据');
return;
}
this.selectList = list;
this.selectShow = true;
};
if (type === '出仓类型') {
this.selectType = type;
const openPicker = (list) => {
if (!list.length) {
this.showError('暂无可选数据');
return;
}
this.selectList = list;
this.selectShow = true;
};
this.ensureOutOrderTypeOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载出仓类型失败'));
} else if (type === '加工单位') {
this.ensureProcessUnitOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载加工单位失败'));
} else if (type === '仓库名称') {
this.ensureWarehouseOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载仓库失败'));
return;
}
const cache = {
'加工单位': this.processUnitOptions,
'仓库名称': this.warehouseOptions,
};
if (cache[type]) this.openSelectPicker(type, cache[type]);
},
selectConfirmFun(e) {
const item = e[0];
@@ -72,7 +72,7 @@
@action="handleStatusAction"
/>
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
</view>
</template>
@@ -56,7 +56,7 @@
<FabricOutFooter :buttons="statusActionButtons" @action="handleStatusAction" />
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
</view>
</template>
@@ -47,7 +47,7 @@
</u-popup>
<u-select v-model="statusSelectShow" :list="statusSelectList" @confirm="onStatusConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" @confirm="onUnitConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" remote :loading="selectSearching" @search="onUnitSearch" @confirm="onUnitConfirm"></u-select>
</view>
</template>
@@ -63,6 +63,7 @@ import {
mapToSelectOptions,
fetchAllOrderList,
} from '@/common/storeGoodsProcessReturnIn';
import { withNameParam } from '@/common/remoteSelect';
export default {
components: { addBtn, ProcessReturnInItem },
@@ -79,6 +80,9 @@ export default {
processUnitOptions: [],
warehouseOptions: [],
unitOptionsLoading: false,
selectSearching: false,
unitSearchSeq: 0,
unitSelectList: [{ value: '', label: '全部' }],
filters: {
order_no: '',
process_unit_id: '',
@@ -104,10 +108,6 @@ export default {
warehouseLabel() {
return this.filters.warehouse_name || '';
},
unitSelectList() {
const options = this.unitSelectType === 'warehouse' ? this.warehouseOptions : this.processUnitOptions;
return [{ value: '', label: '全部' }, ...options];
},
},
onLoad() {
uni.setNavigationBarTitle({ title: '加工退货进仓列表' });
@@ -145,22 +145,40 @@ export default {
return this.warehouseOptions;
});
},
applyUnitSelectList(list) {
const rows = Array.isArray(list) ? list.slice() : [];
this.unitSelectList = [{ value: '', label: '全部' }].concat(rows);
},
openUnitSelect(type) {
if (this.unitOptionsLoading) return;
this.unitOptionsLoading = true;
const loadFn = type === 'warehouse' ? this.loadWarehouseOptions : this.loadProcessUnitOptions;
loadFn.call(this)
.then((list) => {
if (!list.length) {
uni.showToast({ title: '暂无可选数据', icon: 'none' });
return;
}
this.unitSelectType = type;
this.unitSelectShow = true;
})
.finally(() => {
this.unitOptionsLoading = false;
});
this.unitSelectType = type;
const cache = type === 'warehouse' ? this.warehouseOptions : this.processUnitOptions;
this.applyUnitSelectList(cache);
this.unitSelectShow = true;
},
onUnitSearch(keyword) {
const seq = ++this.unitSearchSeq;
const type = this.unitSelectType;
const empty = !String(keyword || '').trim();
this.selectSearching = true;
const req = type === 'warehouse'
? this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
: this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PROCESS }, keyword));
req.then((res) => {
if (seq !== this.unitSearchSeq) return;
const list = mapToSelectOptions(res);
if (empty) {
if (type === 'warehouse') this.warehouseOptions = list;
else this.processUnitOptions = list;
}
this.applyUnitSelectList(list);
}).catch((e) => {
if (seq !== this.unitSearchSeq) return;
uni.showToast({ title: (e && e.message) || '搜索失败', icon: 'none' });
}).then(() => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
}, () => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
});
},
openProcessUnitSelect() {
this.openUnitSelect('process');
@@ -8,6 +8,8 @@
*/
import util from '@/common/util';
import scanMixin from '@/common/scanMixin.js';
import remoteSelectMixin from '@/common/remoteSelectMixin.js';
import { withNameParam } from '@/common/remoteSelect';
import { initTts, speak } from '@/common/tts.js';
import {
AUDIT_STATUS_MAP,
@@ -31,7 +33,7 @@ import {
} from '@/common/storeGoodsProcessReturnIn';
export default {
mixins: [scanMixin],
mixins: [scanMixin, remoteSelectMixin],
data() {
return {
pageMode: 'add',
@@ -284,6 +286,26 @@ export default {
return this.warehouseOptions;
});
},
fetchRemoteSelectOptions(type, keyword) {
const empty = !String(keyword || '').trim();
if (type === '加工单位') {
return this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PROCESS }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.processUnitOptions = list;
return list;
});
}
if (type === '仓库名称') {
return this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.warehouseOptions = list;
return list;
});
}
return Promise.resolve([]);
},
applyDefaultWarehouse() {
const app = getApp();
const picked = pickDefaultWarehouse(
@@ -336,24 +358,11 @@ export default {
},
pickerSelectFun(type) {
if (!this.headerEditable) return;
this.selectType = type;
const openPicker = (list) => {
if (!list.length) {
this.showError('暂无可选数据');
return;
}
this.selectList = list;
this.selectShow = true;
const cache = {
'加工单位': this.processUnitOptions,
'仓库名称': this.warehouseOptions,
};
if (type === '加工单位') {
this.ensureProcessUnitOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载加工单位失败'));
} else if (type === '仓库名称') {
this.ensureWarehouseOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载仓库失败'));
}
if (cache[type]) this.openSelectPicker(type, cache[type]);
},
selectConfirmFun(e) {
const item = e[0];
@@ -107,7 +107,7 @@
@action="handleStatusAction"
/>
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
</view>
</template>
@@ -85,7 +85,7 @@
<FabricOutFooter :buttons="statusActionButtons" @action="handleStatusAction" />
<u-select v-model="selectShow" :list="selectList" @confirm="selectConfirmFun"></u-select>
<u-select v-model="selectShow" :list="selectList" :remote="isRemoteSelect" :loading="selectSearching" @search="onSelectSearch" @confirm="selectConfirmFun"></u-select>
</view>
</template>
@@ -47,7 +47,7 @@
</u-popup>
<u-select v-model="statusSelectShow" :list="statusSelectList" @confirm="onStatusConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" @confirm="onUnitConfirm"></u-select>
<u-select v-model="unitSelectShow" :list="unitSelectList" remote :loading="selectSearching" @search="onUnitSearch" @confirm="onUnitConfirm"></u-select>
</view>
</template>
@@ -63,6 +63,7 @@ import {
mapToSelectOptions,
fetchAllOrderList,
} from '@/common/storeGoodsPurchaseIn';
import { withNameParam } from '@/common/remoteSelect';
export default {
components: { addBtn, PurchaseInItem },
@@ -79,6 +80,9 @@ export default {
supplierOptions: [],
warehouseOptions: [],
unitOptionsLoading: false,
selectSearching: false,
unitSearchSeq: 0,
unitSelectList: [{ value: '', label: '全部' }],
filters: {
order_no: '',
supplier_id: '',
@@ -104,10 +108,6 @@ export default {
warehouseLabel() {
return this.filters.warehouse_name || '';
},
unitSelectList() {
const options = this.unitSelectType === 'warehouse' ? this.warehouseOptions : this.supplierOptions;
return [{ value: '', label: '全部' }, ...options];
},
},
onLoad() {
uni.setNavigationBarTitle({ title: '成品采购进仓' });
@@ -145,22 +145,40 @@ export default {
return this.warehouseOptions;
});
},
applyUnitSelectList(list) {
const rows = Array.isArray(list) ? list.slice() : [];
this.unitSelectList = [{ value: '', label: '全部' }].concat(rows);
},
openUnitSelect(type) {
if (this.unitOptionsLoading) return;
this.unitOptionsLoading = true;
const loadFn = type === 'warehouse' ? this.loadWarehouseOptions : this.loadSupplierOptions;
loadFn.call(this)
.then((list) => {
if (!list.length) {
uni.showToast({ title: '暂无可选数据', icon: 'none' });
return;
}
this.unitSelectType = type;
this.unitSelectShow = true;
})
.finally(() => {
this.unitOptionsLoading = false;
});
this.unitSelectType = type;
const cache = type === 'warehouse' ? this.warehouseOptions : this.supplierOptions;
this.applyUnitSelectList(cache);
this.unitSelectShow = true;
},
onUnitSearch(keyword) {
const seq = ++this.unitSearchSeq;
const type = this.unitSelectType;
const empty = !String(keyword || '').trim();
this.selectSearching = true;
const req = type === 'warehouse'
? this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
: this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER }, keyword));
req.then((res) => {
if (seq !== this.unitSearchSeq) return;
const list = mapToSelectOptions(res);
if (empty) {
if (type === 'warehouse') this.warehouseOptions = list;
else this.supplierOptions = list;
}
this.applyUnitSelectList(list);
}).catch((e) => {
if (seq !== this.unitSearchSeq) return;
uni.showToast({ title: (e && e.message) || '搜索失败', icon: 'none' });
}).then(() => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
}, () => {
if (seq === this.unitSearchSeq) this.selectSearching = false;
});
},
openSupplierSelect() {
this.openUnitSelect('supplier');
@@ -8,6 +8,8 @@
*/
import util from '@/common/util';
import scanMixin from '@/common/scanMixin.js';
import remoteSelectMixin from '@/common/remoteSelectMixin.js';
import { withNameParam } from '@/common/remoteSelect';
import { initTts, speak } from '@/common/tts.js';
import {
AUDIT_STATUS_MAP,
@@ -38,7 +40,7 @@ import {
} from '@/common/storeGoodsPurchaseIn';
export default {
mixins: [scanMixin],
mixins: [scanMixin, remoteSelectMixin],
data() {
return {
pageMode: 'add',
@@ -311,6 +313,34 @@ export default {
return this.saleSystemOptions;
});
},
fetchRemoteSelectOptions(type, keyword) {
const empty = !String(keyword || '').trim();
if (type === '供应商') {
return this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.supplierOptions = list;
return list;
});
}
if (type === '仓库名称') {
return this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.warehouseOptions = list;
return list;
});
}
if (type === '营销体系') {
return this.$u.api.saleSystem.getDropdownList(withNameParam({}, keyword))
.then((res) => {
const list = mapToSelectOptions(res);
if (empty) this.saleSystemOptions = list;
return list;
});
}
return Promise.resolve([]);
},
applyDefaultWarehouse() {
const app = getApp();
const picked = pickDefaultWarehouse(
@@ -394,30 +424,22 @@ export default {
},
pickerSelectFun(type) {
if (!this.headerEditable) return;
this.selectType = type;
const openPicker = (list) => {
if (!list.length) {
if (type === '订单类型') {
this.selectType = type;
if (!this.saleModeOptions.length) {
this.showError('暂无可选数据');
return;
}
this.selectList = list;
this.selectList = this.saleModeOptions;
this.selectShow = true;
};
if (type === '供应商') {
this.ensureSupplierOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载供应商失败'));
} else if (type === '仓库名称') {
this.ensureWarehouseOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载仓库失败'));
} else if (type === '营销体系') {
this.ensureSaleSystemOptions()
.then(openPicker)
.catch((e) => this.showError(e.message || '加载营销体系失败'));
} else if (type === '订单类型') {
openPicker(this.saleModeOptions);
return;
}
const cache = {
'供应商': this.supplierOptions,
'仓库名称': this.warehouseOptions,
'营销体系': this.saleSystemOptions,
};
if (cache[type]) this.openSelectPicker(type, cache[type]);
},
selectConfirmFun(e) {
const item = e[0];
+15 -26
View File
@@ -105,8 +105,8 @@
<!-- </view>-->
<!-- </view>-->
<!-- </div>-->
<u-picker v-model="showApiUrlPicker" mode="selector" :range="apiUrlList" range-key="label"
@confirm="onApiUrlConfirm" @cancel="showApiUrlPicker = false"></u-picker>
<u-select v-model="showApiUrlPicker" :list="apiUrlList" title="选择服务器"
@confirm="onApiUrlConfirm" @cancel="showApiUrlPicker = false"></u-select>
<!-- 版本信息显示 -->
<view class="version-info">
<text class="version-text">版本: {{ appVersion }}</text>
@@ -125,6 +125,7 @@ import md5 from '@/common/md5.js';
import manifest from '@/manifest.json';
import { mapState } from 'vuex'
import app_upgrade from '@/uni_modules/app-upgrade/js_sdk/index.js'
import { applyLoginData, applyUserInformation } from '@/common/userSession.js'
export default {
data() {
return {
@@ -218,9 +219,8 @@ export default {
},
onApiUrlConfirm(e) {
console.log('e', JSON.stringify(e));
const selectedValue = this.apiUrlList[e[0]].value;
console.log('selectedValue', selectedValue)
const selectedValue = e && e[0] && e[0].value;
if (selectedValue == null) return;
this.selectedApiUrl = selectedValue;
this.showApiUrlPicker = false;
@@ -334,11 +334,10 @@ export default {
this.$u.api.pdaLogin({
'phone': this.login.username,
'password': this.login.password,
}).then((res) => {
}).then(async (res) => {
console.log('login res', res)
var aLoginUserData = res;
//console.log('--aLoginUserData->>' + JSON.stringify(aLoginUserData));
// 只在开发环境保存 apiurl 到本地存储
if (config.isDevelopment) {
uni.setStorage({
@@ -347,27 +346,17 @@ export default {
});
util.updateApiUrl(currentApiUrl);
}
// 保存 token 到本地存储
uni.setStorageSync('RemoteTokenData', aLoginUserData);
uni.setStorage({
key: 'userToken',
data: {
Token: aLoginUserData.token,
}
});
applyLoginData(aLoginUserData);
try {
const userInfo = await this.$u.api.pdaGetInformation();
console.log('information res', userInfo);
applyUserInformation(userInfo);
} catch (infoError) {
console.log('information error', infoError);
}
getApp().globalData.Token = aLoginUserData.token;
getApp().globalData.EmployeeID = aLoginUserData.user_id;
getApp().globalData.IsSaleUserStatus = 0;
getApp().globalData.LoginID = aLoginUserData.user_id;
getApp().globalData.LoginName = aLoginUserData.user_name;
getApp().globalData.PlanDepartmentID = aLoginUserData.default_sale_system_id;
getApp().globalData.PlanDepartmentName = aLoginUserData.default_sale_system_name;
getApp().globalData.UserGroup = '';
getApp().globalData.StoreNameID = aLoginUserData.default_physical_warehouse_id;
getApp().globalData.StoreName = aLoginUserData.default_physical_warehouse_name;
getApp().globalData.StoreTypeNo = '';
setTimeout(() => {
uni.reLaunch({
url: '/pages/sys/workbench/index'
+1 -1
View File
@@ -69,7 +69,7 @@ export default {
};
},
onLoad(e) {
this.loginUserName = getApp().globalData.UserName;
this.loginUserName = getApp().globalData.UserName || (this.vuex_user && this.vuex_user.user_name) || '';
},
computed: {
+7 -16
View File
@@ -21,6 +21,7 @@
import app_upgrade from '@/uni_modules/app-upgrade/js_sdk/index.js'
import util from '@/common/util.js';
import config from '../../../common/config';
import { clearUserSession } from '@/common/userSession.js';
export default {
data() {
@@ -84,27 +85,17 @@ export default {
// #endif
},
logout() {
this.$u.api.pdaLogout().then(res => {
console.log('res',res)
if (res.code != 0) {
// this.$u.toast('退出登录失败');
uni.reLaunch({
url: '/pages/sys/login/index'
});
return
}
// 清除token和用户信息
uni.removeStorageSync('token');
this.$store.dispatch('updateUserInfo', null);
const goLogin = () => {
clearUserSession();
uni.reLaunch({
url: '/pages/sys/login/index'
});
};
this.$u.api.pdaLogout().then(() => {
goLogin();
}).catch(error => {
console.log('error',error)
// 即使退出登录失败,也要清除本地token和用户信息
uni.removeStorageSync('token');
this.$store.dispatch('updateUserInfo', null);
// this.$u.toast('退出登录失败');
goLogin();
});
}
}
+75 -47
View File
@@ -7,57 +7,31 @@
</view>
</template>
</common-navbar>
<view class="workbench-title">销售管理</view>
<view class="toolbar">
<u-grid class="grid" :col="4" :border="false">
<u-grid-item :index="0" @click="navTo('/pages/saleship/salepickscan')">
<view class="home-icon icon-color05">
<i class="iconfont icon-hetongguanli"></i>
</view>
<view class="grid-text">成品配布</view>
</u-grid-item>
<!-- <u-grid-item :index="1" @click="navTo('/pages/storegoods/QRBarCodeReview')"> -->
<!-- <view class="home-icon icon-color02"> -->
<!-- <i class="iconfont icon-mall-bag"></i>-->
<!-- </view>-->
<!-- <view class="grid-text">标签检测</view>-->
<!-- </u-grid-item>-->
</u-grid>
</view>
<view class="workbench-title">成品管理</view>
<view class="toolbar">
<u-grid class="grid" :col="4" :border="false">
<u-grid-item :index="2" @click="navTo('/pages/storegoods/storeGoodsProcessInList')">
<view class="home-icon icon-color04">
<i class="iconfont icon-hetongguanli"></i>
</view>
<view class="grid-text">加工进仓</view>
</u-grid-item>
<u-grid-item :index="3" @click="navTo('/pages/storegoods/storeGoodsProcessOutList')">
<view class="home-icon icon-color05">
<i class="iconfont icon-hetongguanli"></i>
</view>
<view class="grid-text">加工出仓</view>
</u-grid-item>
<u-grid-item :index="4" @click="navTo('/pages/storegoods/storeGoodsProcessReturnInList')">
<view class="home-icon icon-color02">
<i class="iconfont icon-hetongguanli"></i>
</view>
<view class="grid-text">加工退货进仓</view>
</u-grid-item>
<u-grid-item :index="5" @click="navTo('/pages/storegoods/storeGoodsPurchaseInList')">
<view class="home-icon icon-color03">
<i class="iconfont icon-hetongguanli"></i>
</view>
<view class="grid-text">采购进仓</view>
</u-grid-item>
</u-grid>
</view>
<view v-for="group in visibleMenuGroups" :key="group.title">
<view class="workbench-title">{{ group.title }}</view>
<view class="toolbar">
<u-grid class="grid" :col="4" :border="false">
<u-grid-item
v-for="(item, index) in group.items"
:key="item.router"
:index="index"
@click="navTo(item.url)"
>
<view class="home-icon" :class="item.color">
<i class="iconfont" :class="item.icon"></i>
</view>
<view class="grid-text">{{ item.name }}</view>
</u-grid-item>
</u-grid>
</view>
</view>
<view v-if="!visibleMenuGroups.length" class="textCenter">暂无可用功能</view>
</view>
</template>
<script>
import CommonNavbar from "@/components/common-navbar/index";
import scanMixin from '@/common/scanMixin.js';
import { hasResourceRouter } from '@/common/userSession.js';
/**
* Copyright (c) 2013-Now http://aidex.vip All rights reserved.
*/
@@ -76,7 +50,53 @@ export default {
//{image: '/static/aidex/banner/banner03.png'}
],
todoCount: 3,
// scanReceiver 和 isPageActive 已由 scanMixin 提供
menuGroups: [
{
title: '销售管理',
items: [
{
name: '成品配布',
url: '/pages/saleship/salepickscan',
router: 'CashCommodityClothOrder',
icon: 'icon-hetongguanli',
color: 'icon-color05'
}
]
},
{
title: '成品管理',
items: [
{
name: '加工进仓',
url: '/pages/storegoods/storeGoodsProcessInList',
router: 'FpProcessingEntryOrder',
icon: 'icon-hetongguanli',
color: 'icon-color04'
},
{
name: '加工出仓',
url: '/pages/storegoods/storeGoodsProcessOutList',
router: 'FpProcessingDeliverFromGodownOrder',
icon: 'icon-hetongguanli',
color: 'icon-color05'
},
{
name: '加工退货进仓',
url: '/pages/storegoods/storeGoodsProcessReturnInList',
router: 'FpProcessingReturnEntryOrder',
icon: 'icon-hetongguanli',
color: 'icon-color02'
},
{
name: '采购进仓',
url: '/pages/storegoods/storeGoodsPurchaseInList',
router: 'FinishPurchaseWarehouseEntry',
icon: 'icon-hetongguanli',
color: 'icon-color03'
}
]
}
]
};
},
@@ -92,6 +112,14 @@ export default {
height: `${navHeight}px`,
};
},
visibleMenuGroups() {
return this.menuGroups
.map((group) => ({
...group,
items: group.items.filter((item) => hasResourceRouter(item.router))
}))
.filter((group) => group.items.length > 0);
}
},
methods: {
// 自定义扫码处理回调 - 处理本页面特有的扫码逻辑