parent
118a4affc9
commit
b15139f55b
@ -0,0 +1,44 @@
|
|||||||
|
import * as api from '@/api/operation/limit/limitProduct.js';
|
||||||
|
import { ElMessage } from '@/plugins/element-plus';
|
||||||
|
const state = () => ({
|
||||||
|
code: 'LimitProduct',
|
||||||
|
condition: {},
|
||||||
|
list: [],
|
||||||
|
total: 0,
|
||||||
|
opts: {
|
||||||
|
init: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const getters = {};
|
||||||
|
const mutations = {
|
||||||
|
setCode: (state, data) => (state.code = data),
|
||||||
|
setCondition: (state, data) => (state.condition = data),
|
||||||
|
setList: (state, data) => (state.list = data),
|
||||||
|
setTotal: (state, data) => (state.total = data),
|
||||||
|
setOpts: (state, data) => (state.opts = data),
|
||||||
|
};
|
||||||
|
const actions = {
|
||||||
|
search: async ({ commit }, id) => {
|
||||||
|
let res = await api.searchSkus(id);
|
||||||
|
commit('setList', res || []);
|
||||||
|
if (!res) {
|
||||||
|
ElMessage.error('查询秒杀商品SKU列表失败');
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
save: async (context, data) => {
|
||||||
|
let res = await api.saveSkus(data);
|
||||||
|
if (res) {
|
||||||
|
ElMessage.success('保存成功');
|
||||||
|
} else {
|
||||||
|
ElMessage.error('保存失败');
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default {
|
||||||
|
state,
|
||||||
|
getters,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
};
|
@ -0,0 +1,110 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model="visible" title="编辑SKU" width="max-content">
|
||||||
|
<TableList
|
||||||
|
v-loading="loading"
|
||||||
|
:code="code"
|
||||||
|
:config="config"
|
||||||
|
:data="list"
|
||||||
|
:operation="[]"
|
||||||
|
style="height: 500px"
|
||||||
|
:total="total"
|
||||||
|
>
|
||||||
|
<template #operation>
|
||||||
|
<el-button type="primary" @click="handleSave">保存</el-button>
|
||||||
|
<h3 style="margin-left: 10px">{{ activityProduct?.productName }}</h3>
|
||||||
|
</template>
|
||||||
|
</TableList>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="jsx">
|
||||||
|
import { ElInputNumber } from 'element-plus/es/components/input-number/index';
|
||||||
|
import 'element-plus/es/components/input-number/style/css';
|
||||||
|
const store = useStore();
|
||||||
|
const loading = ref(false);
|
||||||
|
const visible = ref(false);
|
||||||
|
const code = computed(() => store.state.limitSku.code);
|
||||||
|
const list = computed(() => _.cloneDeep(store.state.limitSku.list));
|
||||||
|
const total = computed(() => store.state.limitSku.total);
|
||||||
|
|
||||||
|
/* 查询订单 */
|
||||||
|
const activityProduct = ref(null);
|
||||||
|
const handleSearch = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
await store.dispatch('limitSku/search', unref(activityProduct).id);
|
||||||
|
loading.value = false;
|
||||||
|
};
|
||||||
|
const emits = defineEmits(['save']);
|
||||||
|
const handleSave = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
await store.dispatch('limitSku/save', {
|
||||||
|
activityProductId: unref(activityProduct).id,
|
||||||
|
activityProductSkuInfoList: unref(list),
|
||||||
|
});
|
||||||
|
emits('save');
|
||||||
|
loading.value = false;
|
||||||
|
};
|
||||||
|
const handleShow = (product) => {
|
||||||
|
activityProduct.value = product;
|
||||||
|
handleSearch();
|
||||||
|
visible.value = true;
|
||||||
|
};
|
||||||
|
const handleClose = () => {
|
||||||
|
visible.value = false;
|
||||||
|
};
|
||||||
|
defineExpose({
|
||||||
|
show: handleShow,
|
||||||
|
close: handleClose,
|
||||||
|
});
|
||||||
|
|
||||||
|
/* 列表配置 */
|
||||||
|
const config = reactive({
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
label: 'SKU属性',
|
||||||
|
prop: 'skuName',
|
||||||
|
minWidth: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '售价(元)',
|
||||||
|
prop: 'originalPrice',
|
||||||
|
width: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '秒杀价(元)',
|
||||||
|
width: 160,
|
||||||
|
slots: {
|
||||||
|
default: ({ row }) => <ElInputNumber v-model={row.price} min={0} />,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '秒杀数量',
|
||||||
|
width: 160,
|
||||||
|
slots: {
|
||||||
|
default: ({ row }) => <ElInputNumber v-model={row.number} min={0} max={row.stock} />,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '剩余数量',
|
||||||
|
prop: 'stock',
|
||||||
|
width: 120,
|
||||||
|
slots: {
|
||||||
|
default: ({ row }) => row.stock || 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '活动已售数量',
|
||||||
|
width: 160,
|
||||||
|
slots: {
|
||||||
|
default: ({ row }) => (row.number || 0) - (row.stock || 0),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.el-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in new issue