| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575 |
- <template>
- <div>
- <PlusPage
- ref="plusPageInstance"
- :columns="tableConfig"
- :request="getList"
- :is-card="true"
- :beforeSearchSubmit="handleBeforeSearch"
- :search="{
- labelWidth: 100,
- showNumber: 3
- }"
- :table="{
- actionBar: { buttons, type: 'link', width: 180 },
- adaptive: { offsetBottom: 50 },
- isSelection: true,
- rowKey: 'id',
- onSelectionChange: handleSelectionChange
- }"
- :pageInfoMap="{ page: 'pageNum', pageSize: 'pageSize' }"
- />
- <!-- 弹窗编辑 -->
- <PlusDialogForm
- ref="dialogForm"
- v-model="form"
- v-model:visible="dialogVisible"
- :form="{
- columns,
- labelPosition: 'left',
- labelWidth: 100,
- rules
- }"
- :dialog="{ title: '跟进', width: 600, confirmLoading }"
- @confirm="handleSubmit"
- @close="handleClose"
- />
- <!-- 跟进状态弹窗 -->
- <plusDialog
- v-model="detailsVisible"
- :hasFooter="false"
- title="跟进记录"
- width="600"
- >
- <plus-descriptions
- :column="4"
- :data="detailForm"
- :columns="detailsColumns"
- :border="false"
- />
- <el-timeline>
- <el-timeline-item
- v-for="item in detailForm.list"
- :key="item.id"
- :timestamp="item.createTime"
- >
- <el-card>
- <el-row>
- <el-col :span="8">
- <el-rate v-model="item.starLevel" disabled />
- </el-col>
- <el-col :span="16">
- <el-tag>{{ item.remark }}</el-tag>
- </el-col>
- </el-row>
- </el-card>
- </el-timeline-item>
- </el-timeline>
- </plusDialog>
- <!-- 重新分配弹窗 -->
- <PlusDialogForm
- ref="resetFormDialog"
- v-model="resetForm"
- v-model:visible="resetVisible"
- :form="{
- columns: resetColumns,
- labelWidth: 100,
- rules: resetRules
- }"
- title="重新分配"
- :dialog="{
- width: 400,
- confirmLoading
- }"
- @confirm="handleResetAccount"
- @close="handleClose"
- />
- </div>
- </template>
- <script lang="ts" setup>
- import {
- computed,
- onMounted,
- reactive,
- ref,
- resolveDirective,
- toRefs
- } from "vue";
- import type { FormRules } from "element-plus";
- import { ElMessage, ElMessageBox } from "element-plus";
- import {
- type FieldValues,
- type PlusColumn,
- PlusDescriptions,
- PlusDialog,
- PlusDialogForm,
- PlusPage,
- PlusPageInstance,
- useTable
- } from "plus-pro-components";
- import { useRouter } from "vue-router";
- import {
- getMerchantOrderInfoAllList,
- getMyOrderInfoAllList,
- merchantFollowInfoAllocationAccount,
- merchantFollowInfoList,
- merchantFollowInfoOrderVisible,
- merchantFollowInfoReliveOrder,
- updateStartLevel
- } from "@/api/order";
- import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
- import { cloneDeep, isString } from "@pureadmin/utils";
- import { getChildAccount } from "@/api/childAccount";
- import { getDictionary } from "@/utils/dictionary";
- import { AesEncode } from "@/utils/crypto";
- defineOptions({
- name: "OrderMy"
- });
- const router = useRouter();
- const plusPageInstance = ref<PlusPageInstance | null>(null);
- const getList = async (query: Record<string, any>) => {
- let res = await getMyOrderInfoAllList(query);
- return {
- data: res.data.list,
- total: res.data.total
- };
- };
- onMounted(() => {
- getChildAccountList();
- });
- // 搜索条件处理
- const handleBeforeSearch = (values: any) => {
- let params = cloneDeep(values);
- if (params.applyTime && params.applyTime.length === 2) {
- Reflect.set(params, "beginTime", values.applyTime[0]);
- Reflect.set(params, "endTime", values.applyTime[1]);
- } else {
- Reflect.deleteProperty(params, "beginTime");
- Reflect.deleteProperty(params, "endTime");
- }
- return params;
- };
- // 重新请求列表接口
- const refresh = () => {
- plusPageInstance.value?.getList();
- };
- const dialogTitle = computed(() => (state.isCreate ? "新增" : "编辑"));
- const multipleSelection = ref([]);
- const handleSelectionChange = (val: any[]) => {
- multipleSelection.value = val;
- };
- const handleReliveOrder = () => {
- if (multipleSelection.value.length === 0) {
- ElMessage.warning("请选择要解除分配的订单");
- return;
- }
- ElMessageBox.confirm("确认解除分配?", "提示").then(async () => {
- try {
- let res = await merchantFollowInfoReliveOrder({
- orderIds: multipleSelection.value.map((item: any) => item.id)
- });
- if (res.code === 0) {
- ElMessage.success("解除分配成功");
- refresh();
- }
- } catch (e) {
- ElMessage.error("删除失败");
- }
- });
- };
- const childAccountList = ref<any[]>([]);
- const getChildAccountList = async () => {
- let res = await getChildAccount();
- childAccountList.value = res.data;
- };
- // 表格数据
- const tableConfig: PlusColumn[] = [
- {
- label: "订单号",
- tableColumnProps: {
- showOverflowTooltip: true
- },
- width: 150,
- prop: "orderNo"
- },
- {
- label: "客户姓名",
- width: 90,
- prop: "userName"
- },
- {
- label: "性别",
- prop: "userSex",
- width: 60,
- hideInSearch: true
- },
- {
- label: "客户星级",
- prop: "star",
- valueType: "rate",
- editable: true,
- width: 140,
- fieldProps: {
- disabled: true
- },
- hideInSearch: true
- },
- {
- label: "客户星级",
- prop: "star",
- valueType: "select",
- options: [
- { label: "1星", value: 1 },
- { label: "2星", value: 2 },
- { label: "3星", value: 3 },
- { label: "4星", value: 4 },
- { label: "5星", value: 5 }
- ],
- hideInTable: true
- },
- {
- label: "电话",
- prop: "maskPhone",
- width: 100,
- hideInSearch: true
- },
- {
- label: "电话",
- prop: "userMobile",
- hideInTable: true
- },
- {
- label: "微信",
- prop: "wxCode",
- tableColumnProps: {
- showOverflowTooltip: true
- },
- hideInSearch: true
- },
- {
- label: "申请产品",
- prop: "productName",
- width: 100,
- hideInSearch: true
- },
- {
- label: "需求资金",
- prop: "loanAmount",
- width: 85,
- hideInSearch: true
- },
- {
- label: "贷款期限",
- prop: "loanTerm",
- width: 100,
- hideInSearch: true,
- formatter: val => getDictionary("LoanLimit", val)
- },
- {
- label: "申请时间",
- prop: "applyTime",
- width: 170,
- valueType: "date-picker",
- fieldProps: {
- type: "datetimerange",
- rangeSeparator: "-",
- valueFormat: "YYYY-MM-DD HH:mm:ss"
- }
- },
- {
- label: "状态",
- prop: "followStatus",
- valueType: "tag",
- width: 80,
- fieldProps: value => ({
- type: value === 0 ? "success" : "primary"
- }),
- formatter: value => (value === 0 ? "待处理" : value === 4 ? "已跟进 " : "")
- },
- {
- label: "备注",
- prop: "remark",
- tableColumnProps: {
- showOverflowTooltip: true
- },
- hideInSearch: true
- }
- ];
- /*--------------------表单--------------------*/
- // 表单实例
- const dialogForm = ref(null);
- interface State {
- dialogVisible: boolean;
- detailsVisible: boolean;
- resetVisible: boolean;
- confirmLoading: boolean;
- selectedIds: number[];
- isCreate: boolean;
- form: {};
- detailForm: {
- list: any;
- };
- resetForm: {};
- rules: FormRules;
- resetRules: FormRules;
- }
- const state = reactive<State>({
- dialogVisible: false,
- detailsVisible: false,
- resetVisible: false,
- confirmLoading: false,
- selectedIds: [],
- isCreate: false,
- form: {},
- detailForm: {
- list: []
- },
- resetForm: {},
- rules: {
- starLevel: [
- { required: true, message: "请选择客户星级", trigger: "change" }
- ]
- },
- resetRules: {
- accountId: [
- { required: true, message: "请选择分配子账号", trigger: "change" }
- ]
- }
- });
- const columns: PlusColumn[] = [
- {
- label: "客户星级",
- prop: "starLevel",
- valueType: "select",
- tooltip: {
- content:
- "<span>客户星级说明</span></br>" +
- "<span>0星:未接通</span></br>" +
- "<span>1星:接通但无办理意向</span></br>" +
- "<span>2星:有意向但无可贷点</span></br>" +
- "<span>3星:有可贷点但资质一般</span></br>" +
- "<span>4星:有可贷点且条件较好</span></br>" +
- "<span>5星:马上需要或条件优质</span></br>",
- rawContent: true
- },
- options: [
- { label: "1星", value: 1 },
- { label: "2星", value: 2 },
- { label: "3星", value: 3 },
- { label: "4星", value: 4 },
- { label: "5星", value: 5 }
- ]
- },
- {
- label: "备注",
- prop: "remark",
- valueType: "input",
- fieldProps: {
- type: "textarea",
- rows: 4,
- maxlength: 200,
- showWordLimit: true
- }
- }
- ];
- const detailsColumns: PlusColumn[] = [
- {
- label: "姓名:",
- prop: "userName"
- },
- {
- label: "需求资金:",
- prop: "loanAmount"
- },
- {
- label: "年龄:",
- prop: "age"
- },
- {
- label: "需求周期:",
- prop: "loanTerm"
- }
- ];
- const resetColumns: PlusColumn[] = [
- {
- label: "分配子账号",
- prop: "accountId",
- valueType: "select",
- options: computed(() => childAccountList.value),
- optionsMap: {
- label: "contractName",
- value: "id"
- }
- }
- ];
- const handleSubmit = async (values: FieldValues) => {
- confirmLoading.value = true;
- try {
- let params = form.value;
- console.log(params);
- let res = await updateStartLevel(params);
- if (res.code === 0) {
- ElMessage.success("修改成功");
- confirmLoading.value = false;
- dialogVisible.value = false;
- refresh();
- } else {
- ElMessage.error(res.msg);
- }
- } finally {
- confirmLoading.value = false;
- }
- };
- const handleResetAccount = async (values: FieldValues) => {
- confirmLoading.value = true;
- try {
- let params = resetForm.value;
- console.log(params);
- let res = await merchantFollowInfoAllocationAccount(params);
- if (res.code === 0) {
- ElMessage.success("重新分配成功");
- resetVisible.value = false;
- refresh();
- } else {
- ElMessage.error(res.msg);
- }
- } catch (e) {
- ElMessage.error("重新分配失败");
- } finally {
- confirmLoading.value = false;
- }
- };
- const handleClose = () => {
- // 重置表单校验状态
- console.log(dialogForm.value.formInstance);
- dialogForm.value.formInstance.resetFields();
- };
- const { buttons } = useTable();
- const perms = resolveDirective("perms");
- const handleReset = () => {
- if (multipleSelection.value.length === 0) {
- ElMessage.warning("请选择要重新分配的订单");
- return;
- }
- resetForm.value = {};
- resetForm.value.id = multipleSelection.value.map((item: any) => item.id);
- console.log(resetForm.value);
- resetVisible.value = true;
- };
- buttons.value = [
- {
- // 修改
- text: "详情",
- code: "edit",
- // props v0.1.16 版本新增函数类型
- props: {
- type: "primary"
- },
- onClick(val) {
- let visibleParams = {
- id: AesEncode(val.row.id)
- };
- merchantFollowInfoOrderVisible(visibleParams).then(res => {
- if (res.code === 0 && res.data.visible === true) {
- let params = {
- id: val.row.id,
- orderNo: val.row.orderNo
- };
- Object.keys(params).forEach(param => {
- if (!isString(params[param])) {
- params[param] = params[param].toString();
- }
- });
- // 保存信息到标签页
- useMultiTagsStoreHook().handleTags("push", {
- path: `/order/order-loan/detail`,
- name: "OrderLoanDetail",
- query: params,
- meta: {
- title: `订单详情`,
- // 如果使用的是非国际化精简版title可以像下面这么写
- // title: `No.${index} - 详情信息`,
- // 最大打开标签数
- dynamicLevel: 1
- }
- });
- // 路由跳转
- router.push({ name: "OrderLoanDetail", query: params });
- } else {
- ElMessage.error(res.data.msg);
- return;
- }
- });
- }
- },
- {
- // 跟进
- text: "跟进",
- props: {
- type: "primary"
- },
- onClick(val) {
- form.value = {};
- form.value.orderId = val.row.orderNo;
- dialogVisible.value = true;
- }
- },
- {
- // 修改
- text: "跟进记录",
- props: {
- type: "primary"
- },
- onClick(val: any) {
- console.log(val.row);
- detailForm.value = val.row;
- detailForm.value.list = [];
- merchantFollowInfoList({ orderNo: val.row.orderNo }).then(res => {
- detailForm.value.list = res.data;
- });
- detailsVisible.value = true;
- }
- }
- ];
- const {
- form,
- detailForm,
- resetForm,
- confirmLoading,
- rules,
- resetRules,
- dialogVisible,
- detailsVisible,
- resetVisible
- } = toRefs(state);
- </script>
|