This commit is contained in:
凌尛 2026-06-29 09:20:49 +08:00
parent bf82e71e85
commit b30fdabd8f
2 changed files with 288 additions and 322 deletions

View File

@ -1052,7 +1052,11 @@ const printNew = async () => {
const LODOP = (await createPrintTask(expressType.value, res.data)) as LODOPObject; const LODOP = (await createPrintTask(expressType.value, res.data)) as LODOPObject;
LODOP.SET_PRINTER_INDEX(printerData.value); LODOP.SET_PRINTER_INDEX(printerData.value);
LODOP.PRINT(); LODOP.PRINT();
faHuo('POSTBBZ', res.data.waybillNo, currentItem.erpOrderId); if (expressType.value == 'YZXB') {
faHuo('POSTBBZ', res.data.waybillNo, currentItem.erpOrderId);
} else {
faHuo(expressType.value, res.data.waybillNo, currentItem.erpOrderId);
}
} }
} catch (error) { } catch (error) {
buttonLoading.value = false; buttonLoading.value = false;
@ -1077,7 +1081,11 @@ const printNew = async () => {
const LODOP = (await createPrintTask(expressType.value, res.data)) as LODOPObject; const LODOP = (await createPrintTask(expressType.value, res.data)) as LODOPObject;
LODOP.SET_PRINTER_INDEX(printerData.value); LODOP.SET_PRINTER_INDEX(printerData.value);
LODOP.PRINT(); LODOP.PRINT();
faHuo('POSTBBZ', res.data.waybillNo, erpOrderId.value); if (expressType.value == 'YZXB') {
faHuo('POSTBBZ', res.data.waybillNo, erpOrderId.value);
} else {
faHuo(expressType.value, res.data.waybillNo, erpOrderId.value);
}
buttonLoading.value = false; buttonLoading.value = false;
dialogCompany.visible = false; dialogCompany.visible = false;
getList(); getList();
@ -1266,7 +1274,7 @@ const getFastMailLabel = (item) => {
return '协议客户号:' + item.partnerId; return '协议客户号:' + item.partnerId;
} else if (item.type == 'JTSD') { } else if (item.type == 'JTSD') {
return '客户编码:' + item.partnerId + ' 客户密码:' + item.secret; return '客户编码:' + item.partnerId + ' 客户密码:' + item.secret;
}else if (item.type == 'YTO') { } else if (item.type == 'YTO') {
return '商家代码:' + item.partnerId + ' 商家秘钥:' + item.secret; return '商家代码:' + item.partnerId + ' 商家秘钥:' + item.secret;
} }
} else if (item.fastMailType == '2') { } else if (item.fastMailType == '2') {

View File

@ -23,10 +23,14 @@
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['zhishu:warehouseSettings:add']">新增</el-button> <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['zhishu:warehouseSettings:add']">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['zhishu:warehouseSettings:edit']">修改</el-button> <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['zhishu:warehouseSettings:edit']"
>修改</el-button
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['zhishu:warehouseSettings:remove']">删除</el-button> <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['zhishu:warehouseSettings:remove']"
>删除</el-button
>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -36,43 +40,42 @@
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="" align="center" prop="id" v-if="false" /> <el-table-column label="" align="center" prop="id" v-if="false" />
<el-table-column label="设置模板名称" align="center" prop="settingName" /> <el-table-column label="设置模板名称" align="center" prop="settingName" />
<el-table-column label="库存同步形式" align="center" prop="stockSynchronizeType" > <el-table-column label="库存同步形式" align="center" prop="stockSynchronizeType">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.stockSynchronizeType === 0">下单减库存</span> <span v-if="scope.row.stockSynchronizeType === 0">下单减库存</span>
<span v-else-if="scope.row.stockSynchronizeType === 1">支付减库存</span> <span v-else-if="scope.row.stockSynchronizeType === 1">支付减库存</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="自动下发" align="center" prop="autoIssue" > <el-table-column label="自动下发" align="center" prop="autoIssue">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.autoIssue === 0">关闭</span> <span v-if="scope.row.autoIssue === 0">关闭</span>
<span v-else-if="scope.row.autoIssue === 1">开启</span> <span v-else-if="scope.row.autoIssue === 1">开启</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="亏损保护" align="center" prop="lossProtection" > <el-table-column label="亏损保护" align="center" prop="lossProtection">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.lossProtection === 0">关闭</span> <span v-if="scope.row.lossProtection === 0">关闭</span>
<span v-else-if="scope.row.lossProtection === 1">开启</span> <span v-else-if="scope.row.lossProtection === 1">开启</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="退款自动回退库存" align="center" prop="stockRollback" > <el-table-column label="退款自动回退库存" align="center" prop="stockRollback">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.stockRollback === 0">关闭</span> <span v-if="scope.row.stockRollback === 0">关闭</span>
<span v-else-if="scope.row.stockRollback === 1">开启</span> <span v-else-if="scope.row.stockRollback === 1">开启</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="状态" align="center" prop="status" > <el-table-column label="状态" align="center" prop="status">
<template #default="scope"> <template #default="scope">
<dict-tag :options="t_is_open" :value="scope.row.status" @click="clickStatus(scope.row)" style="cursor: pointer;" /> <dict-tag :options="t_is_open" :value="scope.row.status" @click="clickStatus(scope.row)" style="cursor: pointer" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="创建时间" align="center" prop="createAt" > <el-table-column label="创建时间" align="center" prop="createAt">
<template #default="scope"> <template #default="scope">
{{ formatTimestamp(scope.row.createAt) }} {{ formatTimestamp(scope.row.createAt) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="修改时间" align="center" prop="updateAt" > <el-table-column label="修改时间" align="center" prop="updateAt">
<template #default="scope"> <template #default="scope">
{{ formatTimestamp(scope.row.updateAt) }} {{ formatTimestamp(scope.row.updateAt) }}
</template> </template>
</el-table-column> </el-table-column>
@ -82,7 +85,13 @@
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['zhishu:warehouseSettings:edit']"></el-button> <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['zhishu:warehouseSettings:edit']"></el-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="删除" placement="top"> <el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['zhishu:warehouseSettings:remove']"></el-button> <el-button
link
type="primary"
icon="Delete"
@click="handleDelete(scope.row)"
v-hasPermi="['zhishu:warehouseSettings:remove']"
></el-button>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
@ -91,66 +100,43 @@
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card> </el-card>
<!-- 新增修改弹窗 --> <!-- 新增修改弹窗 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" @close="resetFormData" width="672px" append-to-body> <el-dialog :title="dialog.title" v-model="dialog.visible" @close="resetFormData" width="672px" append-to-body>
<el-form ref="priceTemplateFormRef" :model="form" :rules="rules" > <el-form ref="priceTemplateFormRef" :model="form" :rules="rules">
<div class="headClass" style="margin-top: 10px">基本规则</div>
<div class="headClass" style="margin-top:10px"> <el-divider style="color: black" />
基本规则
</div>
<el-divider style="color:black"/>
<el-form-item label="应用店铺" prop="templateName" label-width="100px">
<el-select-v2
v-model="chooseShopList"
:options="shopList"
multiple
clearable
collapse-tags
placeholder="选择应用的店铺"
popper-class="custom-header"
:max-collapse-tags="1"
style="width: 240px"
>
<template #header>
<el-checkbox
v-model="checkAll"
:indeterminate="indeterminate"
@change="handleCheckAll"
>
全选
</el-checkbox>
</template>
</el-select-v2>
</el-form-item>
<el-form-item label="应用店铺" prop="templateName" label-width="100px">
<el-select-v2
v-model="chooseShopList"
:options="shopList"
multiple
clearable
collapse-tags
placeholder="选择应用的店铺"
popper-class="custom-header"
:max-collapse-tags="1"
style="width: 240px"
>
<template #header>
<el-checkbox v-model="checkAll" :indeterminate="indeterminate" @change="handleCheckAll"> 全选 </el-checkbox>
</template>
</el-select-v2>
</el-form-item>
<el-form-item label="规则模板名称" prop="templateName" label-width="100px"> <el-form-item label="规则模板名称" prop="templateName" label-width="100px">
<el-input v-model="form.settingName" style="width: 300px" placeholder="请输入模板名称" /> <el-input v-model="form.settingName" style="width: 300px" placeholder="请输入模板名称" />
</el-form-item> </el-form-item>
<el-form-item label="库存同步形式" prop="stockSynchronizeType" label-width="100px" style="width: 100%">
<el-form-item
label="库存同步形式"
prop="stockSynchronizeType"
label-width="100px"
style="width: 100%"
>
<el-radio-group v-model="form.stockSynchronizeType"> <el-radio-group v-model="form.stockSynchronizeType">
<el-radio :key="0" :value="0" disabled>下单减库存</el-radio> <el-radio :key="0" :value="0" disabled>下单减库存</el-radio>
<el-radio :key="1" :value="1">支付减库存</el-radio> <el-radio :key="1" :value="1">支付减库存</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<div style="color:red;margin-top:-25px;font-size:12px;margin-left:2px;margin-bottom:10px">下单减库存功能暂未开放</div> <div style="color: red; margin-top: -25px; font-size: 12px; margin-left: 2px; margin-bottom: 10px">下单减库存功能暂未开放</div>
<el-form-item <el-form-item label="开启自动下发" prop="autoIssue" label-width="100px" style="width: 100%">
label="开启自动下发"
prop="autoIssue"
label-width="100px"
style="width: 100%"
>
<el-radio-group v-model="form.autoIssue"> <el-radio-group v-model="form.autoIssue">
<el-radio :key="0" :value="0"></el-radio> <el-radio :key="0" :value="0"></el-radio>
<el-radio :key="1" :value="1"></el-radio> <el-radio :key="1" :value="1"></el-radio>
@ -158,103 +144,90 @@
</el-form-item> </el-form-item>
<div v-if="form.autoIssue == 1"> <div v-if="form.autoIssue == 1">
<div class="headClass"> <div class="headClass">商品匹配规则</div>
商品匹配规则
</div>
<el-divider /> <el-divider />
<el-form-item <el-form-item label="开启亏损保护" prop="lossProtection" label-width="100px" style="width: 100%">
label="开启亏损保护" <el-radio-group v-model="form.lossProtection">
prop="lossProtection"
label-width="100px"
style="width: 100%"
>
<el-radio-group v-model="form.lossProtection">
<el-radio :key="0" :value="0"></el-radio>
<el-radio :key="1" :value="1"></el-radio>
</el-radio-group>
<el-input v-if="form.lossProtection == 1"
v-model="form.profitFloor"
placeholder="请输入利润下限"
type="number"
style="width:150px;margin-left:20px"
/>
</el-form-item>
<el-table :data="form.ruleList" border style="width: 100%" :cell-style="() => ({ padding: '2px' })">
<!-- 规则内容 -->
<el-table-column label="规则名称" align="center" width="300">
<template #default="scope">
<el-form-item>
<el-select v-model="scope.row.attributeId" placeholder="请选择规则" clearable @change="ruleIdChange(scope.row)">
<el-option v-for="attribute in attributeList" :key="attribute.id" :label="attribute.attributeName" :value="attribute.id" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="规则内容" align="center" width="190">
<template #default="scope">
<el-form-item>
<el-select v-if="scope.row.attributeId == '1'" v-model="scope.row.attributeValue" placeholder="请选择规则值" clearable >
<el-option :key="'0'" :label="'货号优先匹配'" :value="'0'"/>
<el-option :key="'1'" :label="'ISBN优先匹配'" :value="'1'"/>
</el-select>
<el-select v-else-if="scope.row.attributeId == '4'" v-model="scope.row.attributeValue" placeholder="请选择发货地" clearable :loading="loading">
<el-option v-for="item in districtList" :key="item.id" :label="item.name" :value="item.name" />
</el-select>
<el-select v-else-if="scope.row.attributeId == '6'" v-model="scope.row.attributeValue" placeholder="请选择品相" clearable :loading="loading">
<el-option v-for="item in conditionCodeList" :key="item.id" :label="item.value" :value="item.id" />
</el-select>
<el-input v-else
v-model="scope.row.attributeValue"
placeholder="请输入规则内容"
style="width: 100%"
/>
</el-form-item>
</template>
</el-table-column>
<!-- 操作列 -->
<el-table-column label="操作" align="center" width="120">
<template #default="scope">
<el-button
v-if="scope.$index > 0"
type="danger"
icon="Minus"
circle
@click="removeAdjustment(scope.$index)"
/>
<el-button
v-if="scope.$index === form.ruleList.length - 1 && form.ruleList.length < 30"
type="primary"
icon="Plus"
circle
@click="addAdjustment"
/>
</template>
</el-table-column>
</el-table>
</div>
<div class="headClass">
退货规则<span style="color:red;font-size:15px">仅针对未发货订单退款自动回退库存</span>
</div>
<el-divider />
<el-form-item
label="退款后是否自动回退库存"
prop="stockRollback"
label-width="170px"
style="width: 100%"
>
<el-radio-group v-model="form.stockRollback">
<el-radio :key="0" :value="0"></el-radio> <el-radio :key="0" :value="0"></el-radio>
<el-radio :key="1" :value="1"></el-radio> <el-radio :key="1" :value="1"></el-radio>
</el-radio-group> </el-radio-group>
<el-input
v-if="form.lossProtection == 1"
v-model="form.profitFloor"
placeholder="请输入利润下限"
type="number"
style="width: 150px; margin-left: 20px"
/>
</el-form-item> </el-form-item>
<el-table :data="form.ruleList" border style="width: 100%" :cell-style="() => ({ padding: '2px' })">
<!-- 规则内容 -->
<el-table-column label="规则名称" align="center" width="300">
<template #default="scope">
<el-form-item>
<el-select v-model="scope.row.attributeId" placeholder="请选择规则" clearable @change="ruleIdChange(scope.row)">
<el-option v-for="attribute in attributeList" :key="attribute.id" :label="attribute.attributeName" :value="attribute.id" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="规则内容" align="center" width="190">
<template #default="scope">
<el-form-item>
<el-select v-if="scope.row.attributeId == '1'" v-model="scope.row.attributeValue" placeholder="请选择规则值" clearable>
<el-option :key="'0'" :label="'货号优先匹配'" :value="'0'" />
<el-option :key="'1'" :label="'ISBN优先匹配'" :value="'1'" />
</el-select>
<el-select
v-else-if="scope.row.attributeId == '4'"
v-model="scope.row.attributeValue"
placeholder="请选择发货地"
clearable
:loading="loading"
>
<el-option v-for="item in districtList" :key="item.id" :label="item.name" :value="item.name" />
</el-select>
<el-select
v-else-if="scope.row.attributeId == '6'"
v-model="scope.row.attributeValue"
placeholder="请选择品相"
clearable
:loading="loading"
>
<el-option v-for="item in conditionCodeList" :key="item.id" :label="item.value" :value="item.id" />
</el-select>
<el-input v-else v-model="scope.row.attributeValue" placeholder="请输入规则内容" style="width: 100%" />
</el-form-item>
</template>
</el-table-column>
<!-- 操作列 -->
<el-table-column label="操作" align="center" width="120">
<template #default="scope">
<el-button v-if="scope.$index > 0" type="danger" icon="Minus" circle @click="removeAdjustment(scope.$index)" />
<el-button
v-if="scope.$index === form.ruleList.length - 1 && form.ruleList.length < 30"
type="primary"
icon="Plus"
circle
@click="addAdjustment"
/>
</template>
</el-table-column>
</el-table>
</div>
<div class="headClass">退货规则<span style="color: red; font-size: 15px">仅针对未发货订单退款自动回退库存</span></div>
<el-divider />
<el-form-item label="退款后是否自动回退库存" prop="stockRollback" label-width="170px" style="width: 100%">
<el-radio-group v-model="form.stockRollback">
<el-radio :key="0" :value="0"></el-radio>
<el-radio :key="1" :value="1"></el-radio>
</el-radio-group>
</el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -267,21 +240,23 @@
</template> </template>
<script setup name="WarehouseSettings" lang="ts"> <script setup name="WarehouseSettings" lang="ts">
import { listWarehouseSettings, getWarehouseSettings, delWarehouseSettings, addWarehouseSettings, updateWarehouseSettings,getWarehouseSettingsAttribute,updateWarehouseSettingsStatus } from '@/api/zhishu/warehouseSettings'; import {
listWarehouseSettings,
getWarehouseSettings,
delWarehouseSettings,
addWarehouseSettings,
updateWarehouseSettings,
getWarehouseSettingsAttribute,
updateWarehouseSettingsStatus
} from '@/api/zhishu/warehouseSettings';
import { WarehouseSettingsVO, WarehouseSettingsQuery, WarehouseSettingsForm } from '@/api/zhishu/warehouseSettings/types'; import { WarehouseSettingsVO, WarehouseSettingsQuery, WarehouseSettingsForm } from '@/api/zhishu/warehouseSettings/types';
import { getFreInfo, getProvinces } from '@/api/zhishu/district'; import { getFreInfo, getProvinces } from '@/api/zhishu/district';
import { TDistrictVo } from '@/api/zhishu/district/types'; import { TDistrictVo } from '@/api/zhishu/district/types';
import { getListShop } from '@/api/zhishu/shop'; import { getListShop } from '@/api/zhishu/shop';
import type { CheckboxValueType } from 'element-plus' import type { CheckboxValueType } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { const { t_is_open } = toRefs<any>(proxy?.useDict('t_is_open'));
t_is_open
} = toRefs<any>(
proxy?.useDict(
't_is_open'
)
);
const warehouseSettingsList = ref<WarehouseSettingsVO[]>([]); const warehouseSettingsList = ref<WarehouseSettingsVO[]>([]);
const buttonLoading = ref(false); const buttonLoading = ref(false);
@ -296,66 +271,46 @@ const districtList = ref<TDistrictVo[]>([]);
const shopList = ref([]); const shopList = ref([]);
const conditionCodeList = ref([ const conditionCodeList = ref([
{ {
id:"N", id: '100',
value:"全新" value: '全新'
}, },
{ {
id:"M", id: '95',
value:"九五品" value: '九五品'
}, },
{ {
id:"L", id: '90',
value:"九品" value: '九品'
}, },
{ {
id:"K", id: '85',
value:"八五品" value: '八五品'
}, },
{ {
id:"J", id: '80',
value:"八品" value: '八品'
}, },
{ {
id:"I", id: '75',
value:"七五品" value: '七五品'
}, },
{ {
id:"H", id: '70',
value:"七品" value: '七品'
}, },
{ {
id:"G", id: '65',
value:"六五品" value: '六五品'
}, },
{ {
id:"F", id: '60',
value:"六品" value: '六品'
},
{
id:"E",
value:"五品"
},
{
id:"D",
value:"四品"
},
{
id:"C",
value:"三品"
},
{
id:"B",
value:"二品"
},
{
id:"A",
value:"一品"
} }
]) ]);
const checkAll = ref(false) const checkAll = ref(false);
const indeterminate = ref(false) const indeterminate = ref(false);
const chooseShopList = ref<CheckboxValueType[]>([]) const chooseShopList = ref<CheckboxValueType[]>([]);
const queryFormRef = ref<ElFormInstance>(); const queryFormRef = ref<ElFormInstance>();
const warehouseSettingsFormRef = ref<ElFormInstance>(); const warehouseSettingsFormRef = ref<ElFormInstance>();
@ -371,7 +326,7 @@ const initFormData: WarehouseSettingsForm = {
stockSynchronizeType: 1, stockSynchronizeType: 1,
autoIssue: 1, autoIssue: 1,
lossProtection: 1, lossProtection: 1,
profitFloor:undefined, profitFloor: undefined,
status: undefined, status: undefined,
delFlag: undefined, delFlag: undefined,
stockRollback: 1, stockRollback: 1,
@ -379,26 +334,26 @@ const initFormData: WarehouseSettingsForm = {
createAt: undefined, createAt: undefined,
updateBy: undefined, updateBy: undefined,
updateAt: undefined, updateAt: undefined,
shopIds:undefined, shopIds: undefined,
userSettingsAttributeListStr: undefined, userSettingsAttributeListStr: undefined,
ruleList: [ ruleList: [
{ {
id:undefined, id: undefined,
attributeId: undefined, attributeId: undefined,
attributeValue: undefined attributeValue: undefined
} }
] ]
} };
const data = reactive<PageData<WarehouseSettingsForm, WarehouseSettingsQuery>>({ const data = reactive<PageData<WarehouseSettingsForm, WarehouseSettingsQuery>>({
form: {...initFormData}, form: { ...initFormData },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
settingName: undefined, settingName: undefined,
stockSynchronizeType: undefined, stockSynchronizeType: undefined,
autoIssue: undefined, autoIssue: undefined,
lossProtection:undefined, lossProtection: undefined,
profitFloor:undefined, profitFloor: undefined,
status: undefined, status: undefined,
delFlag: undefined, delFlag: undefined,
stockRollback: undefined, stockRollback: undefined,
@ -406,15 +361,12 @@ const data = reactive<PageData<WarehouseSettingsForm, WarehouseSettingsQuery>>({
createAt: undefined, createAt: undefined,
updateBy: undefined, updateBy: undefined,
updateAt: undefined, updateAt: undefined,
shopIds:undefined, shopIds: undefined,
userSettingsAttributeListStr: undefined, userSettingsAttributeListStr: undefined,
params: { params: {}
}
}, },
rules: { rules: {
settingName:[ settingName: [{ required: true, message: '模板名称不能为空', trigger: 'blur' }]
{ required: true, message: "模板名称不能为空", trigger: "blur" }
]
} }
}); });
@ -427,65 +379,65 @@ const getList = async () => {
warehouseSettingsList.value = res.rows; warehouseSettingsList.value = res.rows;
total.value = res.total; total.value = res.total;
loading.value = false; loading.value = false;
} };
/** 取消按钮 */ /** 取消按钮 */
const cancel = () => { const cancel = () => {
reset(); reset();
dialog.visible = false; dialog.visible = false;
} };
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
chooseShopList.value.length = 0; chooseShopList.value.length = 0;
form.value = {...initFormData}; form.value = { ...initFormData };
form.value.ruleList = [{ form.value.ruleList = [
{
id:undefined, id: undefined,
attributeId: undefined, attributeId: undefined,
attributeValue: undefined attributeValue: undefined
}
}]; ];
checkAll.value = false; checkAll.value = false;
warehouseSettingsFormRef.value?.resetFields(); warehouseSettingsFormRef.value?.resetFields();
} };
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
} };
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value?.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} };
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: WarehouseSettingsVO[]) => { const handleSelectionChange = (selection: WarehouseSettingsVO[]) => {
ids.value = selection.map(item => item.id); ids.value = selection.map((item) => item.id);
single.value = selection.length != 1; single.value = selection.length != 1;
multiple.value = !selection.length; multiple.value = !selection.length;
} };
/** 新增按钮操作 */ /** 新增按钮操作 */
const handleAdd = () => { const handleAdd = () => {
reset(); reset();
dialog.visible = true; dialog.visible = true;
dialog.title = "添加设置"; dialog.title = '添加设置';
} };
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row?: WarehouseSettingsVO) => { const handleUpdate = async (row?: WarehouseSettingsVO) => {
reset(); reset();
const _id = row?.id || ids.value[0] const _id = row?.id || ids.value[0];
const res = await getWarehouseSettings(_id); const res = await getWarehouseSettings(_id);
Object.assign(form.value, res.data); Object.assign(form.value, res.data);
dialog.visible = true; dialog.visible = true;
dialog.title = "修改设置"; dialog.title = '修改设置';
/** /**
* 解析后赋值店铺 * 解析后赋值店铺
*/ */
@ -494,14 +446,16 @@ const handleUpdate = async (row?: WarehouseSettingsVO) => {
* 解析后赋值规则 * 解析后赋值规则
*/ */
form.value.ruleList = JSON.parse(res.data.userSettingsAttributeListStr); form.value.ruleList = JSON.parse(res.data.userSettingsAttributeListStr);
if(form.value.ruleList.length == 0){ if (form.value.ruleList.length == 0) {
form.value.ruleList = [{ form.value.ruleList = [
id:undefined, {
id: undefined,
attributeId: undefined, attributeId: undefined,
attributeValue: undefined attributeValue: undefined
}]; }
];
} }
} };
// //
const formatTimestamp = (timestamp: number | undefined | null) => { const formatTimestamp = (timestamp: number | undefined | null) => {
@ -547,77 +501,81 @@ const formatTimestamp = (timestamp: number | undefined | null) => {
/** 提交按钮 */ /** 提交按钮 */
const submitForm = async () => { const submitForm = async () => {
if (chooseShopList.value.length <= 0) {
proxy?.$modal.msgError('请选择应用店铺');
return false;
}
if (!form.value.settingName) {
proxy?.$modal.msgError('规则模板名称不能为空');
return false;
}
if(chooseShopList.value.length <= 0){ if (form.value.autoIssue == 1) {
proxy?.$modal.msgError('请选择应用店铺'); if (
form.value.lossProtection == 1 &&
(form.value.profitFloor == undefined || form.value.profitFloor == null || form.value.profitFloor == '' || form.value.profitFloor < 0)
) {
proxy?.$modal.msgError('利润下限不能为空或小于0');
return false; return false;
} }
if(!form.value.settingName){ for (var i = 0; i < form.value.ruleList.length; i++) {
proxy?.$modal.msgError('规则模板名称不能为空'); if (!form.value.ruleList[i].attributeId) {
return false; proxy?.$modal.msgError('商品匹配规则 第' + (i + 1) + '行,请选择规则');
} return false;
if(form.value.autoIssue == 1){
if(form.value.lossProtection == 1 && (form.value.profitFloor == undefined || form.value.profitFloor == null || form.value.profitFloor == '' || form.value.profitFloor < 0)){
proxy?.$modal.msgError('利润下限不能为空或小于0');
return false;
} }
for(var i=0;i<form.value.ruleList.length;i++){ if (form.value.ruleList[i].attributeId == 7) {
if(!form.value.ruleList[i].attributeId){ form.value.ruleList[i].attributeValue = '不匹配';
proxy?.$modal.msgError('商品匹配规则 第'+(i+1)+"行,请选择规则"); }else if (!form.value.ruleList[i].attributeValue) {
return false; proxy?.$modal.msgError('商品匹配规则 第' + (i + 1) + '行,请填写规则内容');
} return false;
if(!form.value.ruleList[i].attributeValue){
proxy?.$modal.msgError('商品匹配规则 第'+(i+1)+"行,请填写规则内容");
return false;
}
} }
} }
}
let shopIds = '';
for(var i=0;i<chooseShopList.value.length;i++){
if(shopIds == ''){
shopIds = chooseShopList.value[i]
}else{
shopIds += ','+chooseShopList.value[i]
}
}
form.value.shopIds = shopIds;
form.value.userSettingsAttributeListStr = JSON.stringify(form.value.ruleList); let shopIds = '';
for (var i = 0; i < chooseShopList.value.length; i++) {
buttonLoading.value = true; if (shopIds == '') {
if (form.value.id) { shopIds = chooseShopList.value[i];
await updateWarehouseSettings(form.value).finally(() => buttonLoading.value = false);
} else { } else {
await addWarehouseSettings(form.value).finally(() => buttonLoading.value = false); shopIds += ',' + chooseShopList.value[i];
} }
proxy?.$modal.msgSuccess("操作成功"); }
dialog.visible = false; form.value.shopIds = shopIds;
await getList();
} form.value.userSettingsAttributeListStr = JSON.stringify(form.value.ruleList);
buttonLoading.value = true;
if (form.value.id) {
await updateWarehouseSettings(form.value).finally(() => (buttonLoading.value = false));
} else {
await addWarehouseSettings(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
};
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (row?: WarehouseSettingsVO) => { const handleDelete = async (row?: WarehouseSettingsVO) => {
const _ids = row?.id || ids.value; const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除设置编号为"' + _ids + '"的数据项?').finally(() => loading.value = false); await proxy?.$modal.confirm('是否确认删除设置编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delWarehouseSettings(_ids); await delWarehouseSettings(_ids);
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess('删除成功');
await getList(); await getList();
} };
/** 获取匹配属性 */ /** 获取匹配属性 */
const getAttribute = async () => { const getAttribute = async () => {
attributeList.value = await getWarehouseSettingsAttribute() attributeList.value = await getWarehouseSettingsAttribute();
} };
// //
const addAdjustment = () => { const addAdjustment = () => {
const lastItem = form.value.ruleList[form.value.ruleList.length - 1]; const lastItem = form.value.ruleList[form.value.ruleList.length - 1];
form.value.ruleList.push({ form.value.ruleList.push({
id:undefined, id: undefined,
value:undefined value: undefined
}); });
}; };
@ -627,12 +585,12 @@ const removeAdjustment = (index: number) => {
}; };
const ruleIdChange = (row) => { const ruleIdChange = (row) => {
var j=0; var j = 0;
for(var i=0;i<form.value.ruleList.length;i++){ for (var i = 0; i < form.value.ruleList.length; i++) {
if(row.attributeId == form.value.ruleList[i].attributeId){ if (row.attributeId == form.value.ruleList[i].attributeId) {
j++; j++;
} }
if(j > 1){ if (j > 1) {
row.attributeId = undefined; row.attributeId = undefined;
row.attributeValue = undefined; row.attributeValue = undefined;
proxy?.$modal.msgError('请勿重复选择规则'); proxy?.$modal.msgError('请勿重复选择规则');
@ -640,7 +598,7 @@ const ruleIdChange = (row) => {
} }
} }
row.attributeValue = undefined; row.attributeValue = undefined;
} };
/** /**
* 获取发货地 * 获取发货地
@ -654,50 +612,50 @@ const getDistrict = async () => {
* 设置启用禁用 * 设置启用禁用
*/ */
const clickStatus = async (row) => { const clickStatus = async (row) => {
const loading = ElLoading.service({ const loading = ElLoading.service({
lock: true, lock: true,
text: '正在修改规则状态', text: '正在修改规则状态',
background: 'rgba(0, 0, 0, 0.7)', background: 'rgba(0, 0, 0, 0.7)'
}) });
await updateWarehouseSettingsStatus(row).finally(() => loading.close());; await updateWarehouseSettingsStatus(row).finally(() => loading.close());
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess('操作成功');
await getList(); await getList();
} };
/** /**
* 获取店铺列表 * 获取店铺列表
*/ */
const getShops = async () => { const getShops = async () => {
const res = await getListShop(); const res = await getListShop();
for(var i=0;i<res.length;i++){ for (var i = 0; i < res.length; i++) {
shopList.value.push({ shopList.value.push({
value : res[i].id, value: res[i].id,
label : res[i].shopName label: res[i].shopName
}) });
} }
} };
watch(chooseShopList, (val) => { watch(chooseShopList, (val) => {
if (val.length === 0) { if (val.length === 0) {
checkAll.value = false checkAll.value = false;
indeterminate.value = false indeterminate.value = false;
} else if (val.length === shopList.value.length) { } else if (val.length === shopList.value.length) {
checkAll.value = true checkAll.value = true;
indeterminate.value = false indeterminate.value = false;
} else { } else {
indeterminate.value = true indeterminate.value = true;
} }
}) });
const handleCheckAll = (val: CheckboxValueType) => { const handleCheckAll = (val: CheckboxValueType) => {
indeterminate.value = false indeterminate.value = false;
if (val) { if (val) {
chooseShopList.value = shopList.value.map((_) => _.value) chooseShopList.value = shopList.value.map((_) => _.value);
} else { } else {
chooseShopList.value = [] chooseShopList.value = [];
} }
} };
onMounted(() => { onMounted(() => {
getList(); getList();
@ -709,10 +667,10 @@ onMounted(() => {
<style scoped> <style scoped>
.headClass { .headClass {
font-size: 18px; font-size: 18px;
font-weight: 1000; font-weight: 1000;
margin-top: 30px; margin-top: 30px;
margin-bottom: -15px; margin-bottom: -15px;
color: #000000; color: #000000;
} }
</style> </style>