Commit aedf1957 by Lin

feat: 短课程配课接口联调/白名单文件上传接口联调/导出启停接口联调

1 parent 1a970622
...@@ -105,9 +105,17 @@ ...@@ -105,9 +105,17 @@
</div> </div>
</div> </div>
</div> </div>
<div class="upload-tips"> <div v-if="uploadFileList.length > 0" class="upload-tips">
仅支持包含驻店销售手机号的 .xlsx 或 .xls 文件 仅支持包含驻店销售手机号的 .xlsx 或 .xls 文件
</div> </div>
<div v-if="phoneWhitelistStaffList.length > 0"
class="upload-tips import-result-line">
已成功导入{{ phoneWhitelistStaffList.length }}人
<span class="link-like"
@click="openWhiteStaffListDialog">
查看明细
</span>
</div>
</div> </div>
</el-form-item> </el-form-item>
</div> </div>
...@@ -150,14 +158,22 @@ ...@@ -150,14 +158,22 @@
</el-form> </el-form>
</div> </div>
</baseDialog> </baseDialog>
<WhiteStaffList :staff-list="phoneWhitelistStaffList"
:staff-list-visible="whiteStaffListVisible"
@dialogClose="handleWhiteStaffListDialogClose" />
</div> </div>
</template> </template>
<script> <script>
import { getLightChangeConfig, importLightChangePhone, updateLightChangeConfig } from "@api/serviceCentre"; import { getLightChangeConfig, importLightChangePhone, updateLightChangeConfig } from "@api/serviceCentre";
import { effectiveTypeOpt, punishTypeOpt } from "@/common/constants.js"; import { effectiveTypeOpt, punishTypeOpt } from "@/common/constants.js";
import whiteStaffList from "./whiteStaffList.vue";
export default { export default {
name: "ShortLightAlloction",
components: {
WhiteStaffList: whiteStaffList,
},
props: { props: {
shortLightVisible: { shortLightVisible: {
type: Boolean, type: Boolean,
...@@ -186,6 +202,9 @@ export default { ...@@ -186,6 +202,9 @@ export default {
}, },
uploadFileList: [], uploadFileList: [],
whitelistFiles: [], whitelistFiles: [],
/** 白名单 Excel 导入接口返回的 staffList,用于人数展示与明细弹窗 */
phoneWhitelistStaffList: [],
whiteStaffListVisible: false,
configData: { configData: {
effectiveType: "", effectiveType: "",
storePenetrationMonthly: "", storePenetrationMonthly: "",
...@@ -272,6 +291,8 @@ export default { ...@@ -272,6 +291,8 @@ export default {
} else { } else {
this.whitelistFiles = []; this.whitelistFiles = [];
} }
if (Array.isArray(res.staffList))
this.phoneWhitelistStaffList = res.staffList;
}) })
.catch((err) => { .catch((err) => {
console.error(err); console.error(err);
...@@ -286,7 +307,7 @@ export default { ...@@ -286,7 +307,7 @@ export default {
finishTime: this.configData.finishTime, finishTime: this.configData.finishTime,
effectiveType: this.configData.effectiveType, effectiveType: this.configData.effectiveType,
openFlag: this.configData.openFlag === "Y" ? 1 : 0, openFlag: this.configData.openFlag === "Y" ? 1 : 0,
staffList: [{ staffName: "陆汉林", phone: "13800138000" }], staffList: this.phoneWhitelistStaffList,
}; };
console.log(params, "params"); console.log(params, "params");
updateLightChangeConfig(params) updateLightChangeConfig(params)
...@@ -331,6 +352,7 @@ export default { ...@@ -331,6 +352,7 @@ export default {
if (!fileList || fileList.length === 0) { if (!fileList || fileList.length === 0) {
this.whitelistFiles = []; this.whitelistFiles = [];
this.configData.phoneWhitelistFileUrl = ""; this.configData.phoneWhitelistFileUrl = "";
this.phoneWhitelistStaffList = [];
} }
}, },
handleWhitelistFileChange(file) { handleWhitelistFileChange(file) {
...@@ -364,6 +386,7 @@ export default { ...@@ -364,6 +386,7 @@ export default {
const fail = (msg) => { const fail = (msg) => {
this.whitelistFiles = []; this.whitelistFiles = [];
this.configData.phoneWhitelistFileUrl = ""; this.configData.phoneWhitelistFileUrl = "";
this.phoneWhitelistStaffList = [];
this.$refs.whitelistUpload && this.$refs.whitelistUpload.clearFiles(); this.$refs.whitelistUpload && this.$refs.whitelistUpload.clearFiles();
msg && this.$message.error(msg); msg && this.$message.error(msg);
}; };
...@@ -377,18 +400,37 @@ export default { ...@@ -377,18 +400,37 @@ export default {
this.$set(this.whitelistFiles[index], "uploadProgress", percent); this.$set(this.whitelistFiles[index], "uploadProgress", percent);
}; };
// 与 ROP UploadFile / SingleUploadRequest 约定一致:字符串「扩展名@base64正文」(同 importProfit、d2-file-import-dialog)
const reader = new FileReader();
reader.onload = (e) => {
const dataUrl = e.target?.result || "";
const parts = String(dataUrl).split(",");
const b64 = parts[1];
if (!b64) {
fail("文件编码失败,请重试");
return;
}
const ext = (fileInfo.name.split(".").pop() || "xlsx").toLowerCase();
const filePayload = `${ext}@${b64}`;
importLightChangePhone({ importLightChangePhone({
file: fileInfo, file: filePayload,
onProcess, onProcess,
cancelFun: this.whitelistFiles[index].cancelAxios, cancelFun: this.whitelistFiles[index].cancelAxios,
}) })
.then((res) => { .then((res) => {
this.$set(this.whitelistFiles[index], "uploadProgress", 100); this.$set(this.whitelistFiles[index], "uploadProgress", 100);
// 接口 data 内员工列表(axios 拦截器已解包为 data 对象)
const raw = res && typeof res === "object" ? res : {};
const list = Array.isArray(raw.staffList)
? raw.staffList
: (Array.isArray(raw.data?.staffList) ? raw.data.staffList : []);
this.phoneWhitelistStaffList = list;
// 尝试从返回值中取可预览的 url(不同后端可能字段不同) // 尝试从返回值中取可预览的 url(不同后端可能字段不同)
const url = (typeof res === "string" && /^https?:\/\//.test(res)) const url = (typeof res === "string" && /^https?:\/\//.test(res))
? res ? res
: (res?.fileUrl || res?.url || res?.aliyunAddress || ""); : (raw?.fileUrl || raw?.url || raw?.aliyunAddress || "");
if (url) { if (url) {
this.$set(this.whitelistFiles[index], "fileUrl", url); this.$set(this.whitelistFiles[index], "fileUrl", url);
this.configData.phoneWhitelistFileUrl = url; this.configData.phoneWhitelistFileUrl = url;
...@@ -399,6 +441,9 @@ export default { ...@@ -399,6 +441,9 @@ export default {
console.error(err); console.error(err);
fail(err?.message || "上传失败"); fail(err?.message || "上传失败");
}); });
};
reader.onerror = () => fail("读取文件失败");
reader.readAsDataURL(fileInfo);
}, },
handleWhitelistExceed() { handleWhitelistExceed() {
this.$message.error("最多可上传 1 个文件"); this.$message.error("最多可上传 1 个文件");
...@@ -409,14 +454,25 @@ export default { ...@@ -409,14 +454,25 @@ export default {
cancelUploadObj && cancelUploadObj.cancel && cancelUploadObj.cancel(); cancelUploadObj && cancelUploadObj.cancel && cancelUploadObj.cancel();
this.whitelistFiles.splice(subIndex, 1); this.whitelistFiles.splice(subIndex, 1);
this.configData.phoneWhitelistFileUrl = ""; this.configData.phoneWhitelistFileUrl = "";
this.phoneWhitelistStaffList = [];
this.$refs.whitelistUpload && this.$refs.whitelistUpload.clearFiles(); this.$refs.whitelistUpload && this.$refs.whitelistUpload.clearFiles();
}, },
handleWhitelistFileDelete(subIndex) { handleWhitelistFileDelete(subIndex) {
this.whitelistFiles.splice(subIndex, 1); this.whitelistFiles.splice(subIndex, 1);
this.configData.phoneWhitelistFileUrl = ""; this.configData.phoneWhitelistFileUrl = "";
this.phoneWhitelistStaffList = [];
this.uploadFileList = []; this.uploadFileList = [];
this.$refs.whitelistUpload && this.$refs.whitelistUpload.clearFiles(); this.$refs.whitelistUpload && this.$refs.whitelistUpload.clearFiles();
}, },
openWhiteStaffListDialog() {
if (!this.phoneWhitelistStaffList.length)
return;
this.whiteStaffListVisible = true;
},
handleWhiteStaffListDialogClose({ flag, attrName } = {}) {
if (attrName === "staffListVisible")
this.whiteStaffListVisible = !!flag;
},
handleWhitelistFileView(item) { handleWhitelistFileView(item) {
if (item.fileUrl) if (item.fileUrl)
window.open(item.fileUrl, "_blank"); window.open(item.fileUrl, "_blank");
...@@ -543,6 +599,9 @@ export default { ...@@ -543,6 +599,9 @@ export default {
font-weight: 400; font-weight: 400;
line-height: 1.4; line-height: 1.4;
} }
.import-result-line .link-like {
margin-left: 8px;
}
.file-box { .file-box {
width: 100%; width: 100%;
max-width: 380px; max-width: 380px;
......
...@@ -35,15 +35,6 @@ const HEADER_BG = "#F2F4F7"; ...@@ -35,15 +35,6 @@ const HEADER_BG = "#F2F4F7";
/** 表格最大高度(px),超出后表体内部滚动、表头固定 */ /** 表格最大高度(px),超出后表体内部滚动、表头固定 */
const TABLE_MAX_HEIGHT = 420; const TABLE_MAX_HEIGHT = 420;
/** 本地预览用模拟数据;父级传入非空 staffList 时优先展示接口数据 */
const MOCK_STAFF_LIST = [
{ staffName: "张三", staffPhone: "13800138001" },
{ staffName: "李四", staffPhone: "13800138002" },
{ staffName: "王五", staffPhone: "13900139000" },
{ staffName: "赵六", staffPhone: "13700137000" },
{ staffName: "赵六", staffPhone: "13700137000" },
];
export default { export default {
name: "WhiteStaffList", name: "WhiteStaffList",
props: { props: {
...@@ -87,9 +78,7 @@ export default { ...@@ -87,9 +78,7 @@ export default {
}, },
}, },
displayList() { displayList() {
return this.staffList && this.staffList.length return Array.isArray(this.staffList) ? this.staffList : [];
? this.staffList
: MOCK_STAFF_LIST;
}, },
}, },
methods: { methods: {
......
...@@ -67,13 +67,6 @@ ...@@ -67,13 +67,6 @@
导出 导出
</el-button> </el-button>
</span> </span>
<span style="margin-left: 10px">
<el-button size="small"
type="primary"
@click="handleOpenStaffList">
适用人员
</el-button>
</span>
</div> </div>
</div> </div>
</div> </div>
...@@ -258,10 +251,6 @@ ...@@ -258,10 +251,6 @@
:short-light-visible="shortLightVisible" :short-light-visible="shortLightVisible"
@dialogClose="handleShortLightCloseDialog"> @dialogClose="handleShortLightCloseDialog">
</ShortLightAlloction> </ShortLightAlloction>
<WhiteStaffList v-if="staffListVisible"
:staff-list="staffListData"
:staff-list-visible="staffListVisible"
@dialogClose="handleStaffListClose" />
</d2-container> </d2-container>
</template> </template>
...@@ -279,7 +268,6 @@ import shortAllocation from "./components/shortAllocation"; ...@@ -279,7 +268,6 @@ import shortAllocation from "./components/shortAllocation";
import shortDetailDialog from "./components/shortDetailDialog"; import shortDetailDialog from "./components/shortDetailDialog";
import shortLightAlloction from "./components/shortLightAlloction.vue"; import shortLightAlloction from "./components/shortLightAlloction.vue";
import ShortLightDetail from "./components/shortLightDetail.vue"; import ShortLightDetail from "./components/shortLightDetail.vue";
import whiteStaffList from "./components/whiteStaffList.vue";
import LightChange from "./lightChange.vue"; import LightChange from "./lightChange.vue";
const thirtyOneDaysAgo = new Date(); const thirtyOneDaysAgo = new Date();
...@@ -293,7 +281,6 @@ export default { ...@@ -293,7 +281,6 @@ export default {
LightChange, LightChange,
ShortLightAlloction: shortLightAlloction, ShortLightAlloction: shortLightAlloction,
ShortLightDetail, ShortLightDetail,
WhiteStaffList: whiteStaffList,
}, },
data() { data() {
return { return {
...@@ -357,7 +344,8 @@ export default { ...@@ -357,7 +344,8 @@ export default {
optionList: [], optionList: [],
optionId: "confId", optionId: "confId",
optionLabel: "confValue", optionLabel: "confValue",
optionsName: "taskStatusOpt", // 轻改业务:接口筛选值为 0/1(进行中/已结束),延保业务仍为 1/2
optionsName: "lightTaskStatusOpt",
}, },
{ {
label: "复盘时间", label: "复盘时间",
...@@ -568,6 +556,10 @@ export default { ...@@ -568,6 +556,10 @@ export default {
// useStatusOpt: deepClone(useStatusOpt), // useStatusOpt: deepClone(useStatusOpt),
punishTypeOpt: deepClone(punishTypeOpt), punishTypeOpt: deepClone(punishTypeOpt),
taskStatusOpt: deepClone(taskStatusOpt), taskStatusOpt: deepClone(taskStatusOpt),
lightTaskStatusOpt: [
{ confId: "0", confValue: "进行中" },
{ confId: "1", confValue: "已结束" },
],
punishStatusOpt: deepClone(punishStatusOpt), punishStatusOpt: deepClone(punishStatusOpt),
businessSceneTypeNameOpt: [ businessSceneTypeNameOpt: [
{ confId: "轻改", confValue: "轻改" }, { confId: "轻改", confValue: "轻改" },
...@@ -577,8 +569,6 @@ export default { ...@@ -577,8 +569,6 @@ export default {
}, },
recordInfo: null, recordInfo: null,
detailVisible: false, detailVisible: false,
staffListVisible: false,
staffListData: [],
}; };
}, },
computed: { computed: {
...@@ -597,6 +587,40 @@ export default { ...@@ -597,6 +587,40 @@ export default {
close: "d2admin/page/close", close: "d2admin/page/close",
}), }),
...mapActions("d2admin/user", ["actionSetDownloadList"]), ...mapActions("d2admin/user", ["actionSetDownloadList"]),
getDefaultSearchForm() {
return {
businessSceneTypeName: "",
staffName: "",
staffPhone: "",
merchantName: "",
mainBrand: "",
punishType: "",
taskStatus: "",
checkTime: [thirtyOneDaysAgo, new Date()],
finishTime: [],
};
},
getDefaultLightSearchForm() {
return {
staffName: "",
staffPhone: "",
merchantName: "",
taskStatus: "",
checkTime: [thirtyOneDaysAgo, new Date()],
finishTime: [],
};
},
resetObjectInPlace(target, defaults) {
// 保持引用不变,确保 d2-search / el-input 等受控组件立即同步
Object.keys(defaults).forEach((k) => {
this.$set(target, k, defaults[k]);
});
Object.keys(target).forEach((k) => {
if (!Object.prototype.hasOwnProperty.call(defaults, k)) {
this.$delete(target, k);
}
});
},
handleTabClick() { handleTabClick() {
this.$nextTick(() => { this.$nextTick(() => {
this.handleReset(); this.handleReset();
...@@ -632,9 +656,6 @@ export default { ...@@ -632,9 +656,6 @@ export default {
this.shortLightVisible = false; this.shortLightVisible = false;
this.handleSearch(); this.handleSearch();
}, },
handleOpenStaffList() {
this.staffListVisible = true;
},
handleOpenShortLightDetail(payload) { handleOpenShortLightDetail(payload) {
// 入口按钮:确保切换到轻改业务后再展示弹窗 // 入口按钮:确保切换到轻改业务后再展示弹窗
if (this.activeName !== "qinggai") { if (this.activeName !== "qinggai") {
...@@ -646,11 +667,6 @@ export default { ...@@ -646,11 +667,6 @@ export default {
this.shortLightDetailVisible = true; this.shortLightDetailVisible = true;
}); });
}, },
handleStaffListClose({ flag, attrName }) {
if (attrName) {
this[attrName] = flag;
}
},
closeShortLightDetailDialog({ flag }) { closeShortLightDetailDialog({ flag }) {
this.shortLightDetailVisible = !!flag; this.shortLightDetailVisible = !!flag;
}, },
...@@ -739,27 +755,12 @@ export default { ...@@ -739,27 +755,12 @@ export default {
}, },
handleReset() { handleReset() {
if (this.activeName === "yanbao") { if (this.activeName === "yanbao") {
this.searchForm = { const defaults = this.getDefaultSearchForm();
staffName: "", this.resetObjectInPlace(this.searchForm, defaults);
staffPhone: "",
merchantName: "",
mainBrand: "",
punishType: "",
taskStatus: "",
checkTime: [thirtyOneDaysAgo, new Date()], // 复盘时间
finishTime: [],
businessSceneTypeName: "",
};
this.$refs.shortTable && this.$refs.shortTable.refreshTable(); this.$refs.shortTable && this.$refs.shortTable.refreshTable();
} else { } else {
this.lightSearchForm = { const defaults = this.getDefaultLightSearchForm();
staffName: "", this.resetObjectInPlace(this.lightSearchForm, defaults);
staffPhone: "",
merchantName: "",
taskStatus: "",
checkTime: [thirtyOneDaysAgo, new Date()],
finishTime: [],
};
this.$refs.lightChangeRef this.$refs.lightChangeRef
&& this.$refs.lightChangeRef.refreshTable(); && this.$refs.lightChangeRef.refreshTable();
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!