Commit aedf1957 by Lin

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

1 parent 1a970622
......@@ -105,9 +105,17 @@
</div>
</div>
</div>
<div class="upload-tips">
<div v-if="uploadFileList.length > 0" class="upload-tips">
仅支持包含驻店销售手机号的 .xlsx 或 .xls 文件
</div>
<div v-if="phoneWhitelistStaffList.length > 0"
class="upload-tips import-result-line">
已成功导入{{ phoneWhitelistStaffList.length }}人
<span class="link-like"
@click="openWhiteStaffListDialog">
查看明细
</span>
</div>
</div>
</el-form-item>
</div>
......@@ -150,14 +158,22 @@
</el-form>
</div>
</baseDialog>
<WhiteStaffList :staff-list="phoneWhitelistStaffList"
:staff-list-visible="whiteStaffListVisible"
@dialogClose="handleWhiteStaffListDialogClose" />
</div>
</template>
<script>
import { getLightChangeConfig, importLightChangePhone, updateLightChangeConfig } from "@api/serviceCentre";
import { effectiveTypeOpt, punishTypeOpt } from "@/common/constants.js";
import whiteStaffList from "./whiteStaffList.vue";
export default {
name: "ShortLightAlloction",
components: {
WhiteStaffList: whiteStaffList,
},
props: {
shortLightVisible: {
type: Boolean,
......@@ -186,6 +202,9 @@ export default {
},
uploadFileList: [],
whitelistFiles: [],
/** 白名单 Excel 导入接口返回的 staffList,用于人数展示与明细弹窗 */
phoneWhitelistStaffList: [],
whiteStaffListVisible: false,
configData: {
effectiveType: "",
storePenetrationMonthly: "",
......@@ -272,6 +291,8 @@ export default {
} else {
this.whitelistFiles = [];
}
if (Array.isArray(res.staffList))
this.phoneWhitelistStaffList = res.staffList;
})
.catch((err) => {
console.error(err);
......@@ -286,7 +307,7 @@ export default {
finishTime: this.configData.finishTime,
effectiveType: this.configData.effectiveType,
openFlag: this.configData.openFlag === "Y" ? 1 : 0,
staffList: [{ staffName: "陆汉林", phone: "13800138000" }],
staffList: this.phoneWhitelistStaffList,
};
console.log(params, "params");
updateLightChangeConfig(params)
......@@ -331,6 +352,7 @@ export default {
if (!fileList || fileList.length === 0) {
this.whitelistFiles = [];
this.configData.phoneWhitelistFileUrl = "";
this.phoneWhitelistStaffList = [];
}
},
handleWhitelistFileChange(file) {
......@@ -364,6 +386,7 @@ export default {
const fail = (msg) => {
this.whitelistFiles = [];
this.configData.phoneWhitelistFileUrl = "";
this.phoneWhitelistStaffList = [];
this.$refs.whitelistUpload && this.$refs.whitelistUpload.clearFiles();
msg && this.$message.error(msg);
};
......@@ -377,28 +400,50 @@ export default {
this.$set(this.whitelistFiles[index], "uploadProgress", percent);
};
importLightChangePhone({
file: fileInfo,
onProcess,
cancelFun: this.whitelistFiles[index].cancelAxios,
})
.then((res) => {
this.$set(this.whitelistFiles[index], "uploadProgress", 100);
// 尝试从返回值中取可预览的 url(不同后端可能字段不同)
const url = (typeof res === "string" && /^https?:\/\//.test(res))
? res
: (res?.fileUrl || res?.url || res?.aliyunAddress || "");
if (url) {
this.$set(this.whitelistFiles[index], "fileUrl", url);
this.configData.phoneWhitelistFileUrl = url;
}
this.$message.success("上传成功");
// 与 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({
file: filePayload,
onProcess,
cancelFun: this.whitelistFiles[index].cancelAxios,
})
.catch((err) => {
console.error(err);
fail(err?.message || "上传失败");
});
.then((res) => {
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(不同后端可能字段不同)
const url = (typeof res === "string" && /^https?:\/\//.test(res))
? res
: (raw?.fileUrl || raw?.url || raw?.aliyunAddress || "");
if (url) {
this.$set(this.whitelistFiles[index], "fileUrl", url);
this.configData.phoneWhitelistFileUrl = url;
}
this.$message.success("上传成功");
})
.catch((err) => {
console.error(err);
fail(err?.message || "上传失败");
});
};
reader.onerror = () => fail("读取文件失败");
reader.readAsDataURL(fileInfo);
},
handleWhitelistExceed() {
this.$message.error("最多可上传 1 个文件");
......@@ -409,14 +454,25 @@ export default {
cancelUploadObj && cancelUploadObj.cancel && cancelUploadObj.cancel();
this.whitelistFiles.splice(subIndex, 1);
this.configData.phoneWhitelistFileUrl = "";
this.phoneWhitelistStaffList = [];
this.$refs.whitelistUpload && this.$refs.whitelistUpload.clearFiles();
},
handleWhitelistFileDelete(subIndex) {
this.whitelistFiles.splice(subIndex, 1);
this.configData.phoneWhitelistFileUrl = "";
this.phoneWhitelistStaffList = [];
this.uploadFileList = [];
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) {
if (item.fileUrl)
window.open(item.fileUrl, "_blank");
......@@ -543,6 +599,9 @@ export default {
font-weight: 400;
line-height: 1.4;
}
.import-result-line .link-like {
margin-left: 8px;
}
.file-box {
width: 100%;
max-width: 380px;
......
......@@ -35,15 +35,6 @@ const HEADER_BG = "#F2F4F7";
/** 表格最大高度(px),超出后表体内部滚动、表头固定 */
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 {
name: "WhiteStaffList",
props: {
......@@ -87,9 +78,7 @@ export default {
},
},
displayList() {
return this.staffList && this.staffList.length
? this.staffList
: MOCK_STAFF_LIST;
return Array.isArray(this.staffList) ? this.staffList : [];
},
},
methods: {
......
......@@ -67,13 +67,6 @@
导出
</el-button>
</span>
<span style="margin-left: 10px">
<el-button size="small"
type="primary"
@click="handleOpenStaffList">
适用人员
</el-button>
</span>
</div>
</div>
</div>
......@@ -258,10 +251,6 @@
:short-light-visible="shortLightVisible"
@dialogClose="handleShortLightCloseDialog">
</ShortLightAlloction>
<WhiteStaffList v-if="staffListVisible"
:staff-list="staffListData"
:staff-list-visible="staffListVisible"
@dialogClose="handleStaffListClose" />
</d2-container>
</template>
......@@ -279,7 +268,6 @@ import shortAllocation from "./components/shortAllocation";
import shortDetailDialog from "./components/shortDetailDialog";
import shortLightAlloction from "./components/shortLightAlloction.vue";
import ShortLightDetail from "./components/shortLightDetail.vue";
import whiteStaffList from "./components/whiteStaffList.vue";
import LightChange from "./lightChange.vue";
const thirtyOneDaysAgo = new Date();
......@@ -293,7 +281,6 @@ export default {
LightChange,
ShortLightAlloction: shortLightAlloction,
ShortLightDetail,
WhiteStaffList: whiteStaffList,
},
data() {
return {
......@@ -357,7 +344,8 @@ export default {
optionList: [],
optionId: "confId",
optionLabel: "confValue",
optionsName: "taskStatusOpt",
// 轻改业务:接口筛选值为 0/1(进行中/已结束),延保业务仍为 1/2
optionsName: "lightTaskStatusOpt",
},
{
label: "复盘时间",
......@@ -568,6 +556,10 @@ export default {
// useStatusOpt: deepClone(useStatusOpt),
punishTypeOpt: deepClone(punishTypeOpt),
taskStatusOpt: deepClone(taskStatusOpt),
lightTaskStatusOpt: [
{ confId: "0", confValue: "进行中" },
{ confId: "1", confValue: "已结束" },
],
punishStatusOpt: deepClone(punishStatusOpt),
businessSceneTypeNameOpt: [
{ confId: "轻改", confValue: "轻改" },
......@@ -577,8 +569,6 @@ export default {
},
recordInfo: null,
detailVisible: false,
staffListVisible: false,
staffListData: [],
};
},
computed: {
......@@ -597,6 +587,40 @@ export default {
close: "d2admin/page/close",
}),
...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() {
this.$nextTick(() => {
this.handleReset();
......@@ -632,9 +656,6 @@ export default {
this.shortLightVisible = false;
this.handleSearch();
},
handleOpenStaffList() {
this.staffListVisible = true;
},
handleOpenShortLightDetail(payload) {
// 入口按钮:确保切换到轻改业务后再展示弹窗
if (this.activeName !== "qinggai") {
......@@ -646,11 +667,6 @@ export default {
this.shortLightDetailVisible = true;
});
},
handleStaffListClose({ flag, attrName }) {
if (attrName) {
this[attrName] = flag;
}
},
closeShortLightDetailDialog({ flag }) {
this.shortLightDetailVisible = !!flag;
},
......@@ -739,27 +755,12 @@ export default {
},
handleReset() {
if (this.activeName === "yanbao") {
this.searchForm = {
staffName: "",
staffPhone: "",
merchantName: "",
mainBrand: "",
punishType: "",
taskStatus: "",
checkTime: [thirtyOneDaysAgo, new Date()], // 复盘时间
finishTime: [],
businessSceneTypeName: "",
};
const defaults = this.getDefaultSearchForm();
this.resetObjectInPlace(this.searchForm, defaults);
this.$refs.shortTable && this.$refs.shortTable.refreshTable();
} else {
this.lightSearchForm = {
staffName: "",
staffPhone: "",
merchantName: "",
taskStatus: "",
checkTime: [thirtyOneDaysAgo, new Date()],
finishTime: [],
};
const defaults = this.getDefaultLightSearchForm();
this.resetObjectInPlace(this.lightSearchForm, defaults);
this.$refs.lightChangeRef
&& 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!