New file |
| | |
| | | <script lang="ts" name="fBS_Customer" setup> |
| | | import { ref, reactive, onMounted } from "vue"; |
| | | import type { FormRules } from "element-plus"; |
| | | import { formatDate } from '/@/utils/formatTime'; |
| | | import { useFBS_CustomerApi } from '/@/api/Customer/fBS_Customer'; |
| | | import { useFBS_CusExtendApi } from '/@/api/Customer/fBS_CusExtend'; |
| | | import { auth } from '/@/utils/authFunction'; |
| | | import { ElMessageBox, ElMessage } from "element-plus"; |
| | | import { downloadStreamFile } from "/@/utils/download"; |
| | | import editDialog from '/@/views/Customer/fBS_CusExtend/component/fBS_Customer/component/editDialog.vue' |
| | | import printDialog from '/@/views/system/print/component/hiprint/preview.vue' |
| | | import ModifyRecord from '/@/components/table/modifyRecord.vue'; |
| | | import ImportData from "/@/components/table/importData.vue"; |
| | | |
| | | const fBS_CusExtendApi = useFBS_CusExtendApi(); |
| | | |
| | | const fBS_CustomerApi = useFBS_CustomerApi(); |
| | | const printDialogRef = ref(); |
| | | const editDialogRef = ref(); |
| | | const importDataRef = ref(); |
| | | const state = reactive({ |
| | | title: '', |
| | | loading: false, |
| | | showDialog: false, |
| | | ruleForm: {} as any, |
| | | stores: {}, |
| | | dropdownData: {} as any, |
| | | exportLoading: false, |
| | | tableLoading: false, |
| | | showAdvanceQueryUI: false, |
| | | selectData: [] as any[], |
| | | tableQueryParams: {} as any, |
| | | tableParams: { |
| | | page: 1, |
| | | pageSize: 20, |
| | | total: 0, |
| | | field: 'createTime', // 默认的排序字段 |
| | | order: 'descending', // 排序方向 |
| | | descStr: 'descending', // 降序排序的关键字符 |
| | | }, |
| | | tableData: [], |
| | | listRow:{} |
| | | }); |
| | | |
| | | // 页面加载时 |
| | | onMounted(async () => { |
| | | }); |
| | | |
| | | /** |
| | | * 根据id对数组元素进行操作:存在则替换,不存在则添加,指定删除则移除 |
| | | * @param {Array} array - 要操作的原数组 |
| | | * @param {Object} item - 要操作的元素,必须包含id属性 |
| | | * @param {boolean} [deleteFlag=false] - 是否执行删除操作 |
| | | * @returns {Array} 处理后的数组 |
| | | */ |
| | | function operateByid(array, item, deleteFlag = false) { |
| | | // 检查元素是否包含id |
| | | // if (!item || !('id' in item)) { |
| | | // console.warn('元素必须包含id属性'); |
| | | // return [...array]; |
| | | // } |
| | | |
| | | // 创建原数组的副本,避免直接修改原数组 |
| | | const newArray = [...array]; |
| | | // 查找数组中是否存在相同id的元素 |
| | | const index = newArray.findIndex(i => i.id === item.id); |
| | | |
| | | if (deleteFlag) { |
| | | // 如果需要删除且元素存在,则从数组中移除 |
| | | if (index !== -1) { |
| | | newArray.splice(index, 1); |
| | | } |
| | | } else { |
| | | if (index !== -1) { |
| | | // 存在则替换 |
| | | newArray[index] = item; |
| | | } else { |
| | | // 不存在则添加 |
| | | newArray.push(item); |
| | | } |
| | | } |
| | | |
| | | return newArray; |
| | | } |
| | | // 查询操作 |
| | | const handleQuery = async (params: any = {}, deleteFlag:false) => { |
| | | // state.tableLoading = true; |
| | | // state.tableData = operateByid(state.tableData,params,deleteFlag) |
| | | // console.log(params); |
| | | |
| | | // state.tableLoading = false; |
| | | }; |
| | | |
| | | // 列排序 |
| | | const sortChange = async (column: any) => { |
| | | state.tableParams.field = column.prop; |
| | | state.tableParams.order = column.order; |
| | | await handleQuery(); |
| | | }; |
| | | |
| | | // 删除 |
| | | const delFBS_Customer = (row: any) => { |
| | | console.log(row,'rowrow'); |
| | | |
| | | ElMessageBox.confirm(`确定要删除吗?`, "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(async () => { |
| | | await fBS_CusExtendApi.delCustormerUser(row.id); |
| | | handleQuery(row,true); |
| | | ElMessage.success("删除成功"); |
| | | }).catch(() => {}); |
| | | }; |
| | | |
| | | // 批量删除 |
| | | const batchDelFBS_Customer = () => { |
| | | ElMessageBox.confirm(`确定要删除${state.selectData.length}条记录吗?`, "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(async () => { |
| | | await fBS_CustomerApi.batchDelete(state.selectData.map(u => ({ id: u.id }) )).then(res => { |
| | | ElMessage.success(`成功批量删除${res.data.result}条记录`); |
| | | handleQuery(); |
| | | }); |
| | | }).catch(() => {}); |
| | | }; |
| | | |
| | | const applyFBS_Customer = async(row: any,val:Number)=>{ |
| | | let res = await fBS_CusExtendApi.changeSteps(row.id,val); |
| | | if(res.data.code==200){ |
| | | ElMessage({ |
| | | message: `通过成功!`, |
| | | type: "success", |
| | | }); |
| | | row.steps = val |
| | | }else{ |
| | | ElMessage({ |
| | | message: res.message||`通过失败!`, |
| | | type: "error", |
| | | }); |
| | | } |
| | | } |
| | | |
| | | const noFBS_Customer=(row: any,val:Number)=>{ |
| | | ElMessageBox.confirm(`确定不通过吗?`, "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(async () => { |
| | | let res = await fBS_CusExtendApi.changeSteps(row.id,val); |
| | | if(res.data.code==200){ |
| | | ElMessage({ |
| | | message: `不通过成功!`, |
| | | type: "success", |
| | | }); |
| | | row.steps = val |
| | | }else{ |
| | | ElMessage({ |
| | | message: res.message||`不通过失败!`, |
| | | type: "error", |
| | | }); |
| | | } |
| | | }).catch(() => {}); |
| | | } |
| | | |
| | | // // 设置状态 |
| | | // const changeFBS_CustomerStatus = async (row: any) => { |
| | | // await fBS_CusExtendApi.setStatus({ id: row.id, status: row.status }).then(() => ElMessage.success('状态设置成功')); |
| | | // }; |
| | | |
| | | // 导出数据 |
| | | const exportFBS_CustomerCommand = async (command: string) => { |
| | | try { |
| | | state.exportLoading = true; |
| | | if (command === 'select') { |
| | | const params = Object.assign({}, state.tableQueryParams, state.tableParams, { selectKeyList: state.selectData.map(u => u.id) }); |
| | | await fBS_CustomerApi.exportData(params).then(res => downloadStreamFile(res)); |
| | | } else if (command === 'current') { |
| | | const params = Object.assign({}, state.tableQueryParams, state.tableParams); |
| | | await fBS_CustomerApi.exportData(params).then(res => downloadStreamFile(res)); |
| | | } else if (command === 'all') { |
| | | const params = Object.assign({}, state.tableQueryParams, state.tableParams, { page: 1, pageSize: 99999999 }); |
| | | await fBS_CustomerApi.exportData(params).then(res => downloadStreamFile(res)); |
| | | } |
| | | } finally { |
| | | state.exportLoading = false; |
| | | } |
| | | } |
| | | |
| | | handleQuery(); |
| | | //父级传递来的函数,用于回调 |
| | | const emit = defineEmits(["reloadTable"]); |
| | | const ruleFormRef = ref(); |
| | | |
| | | |
| | | |
| | | |
| | | // 页面加载时 |
| | | onMounted(async () => { |
| | | }); |
| | | |
| | | // 打开弹窗 |
| | | const openDialog = async (row: any, title: string) => { |
| | | state.tableLoading = true; |
| | | state.title = title; |
| | | let res = JSON.parse(JSON.stringify(row)) |
| | | state.tableData = res.exRoles |
| | | state.listRow = row |
| | | state.tableLoading = false; |
| | | state.showDialog = true; |
| | | }; |
| | | |
| | | // 关闭弹窗 |
| | | const closeDialog = () => { |
| | | emit("reloadTable"); |
| | | state.showDialog = false; |
| | | }; |
| | | |
| | | // 提交 |
| | | const submit = async () => { |
| | | closeDialog(); |
| | | }; |
| | | |
| | | //将属性或者函数暴露给父组件 |
| | | defineExpose({ openDialog }); |
| | | </script> |
| | | <template> |
| | | <div class="fBS_Customer-container"> |
| | | <el-dialog v-model="state.showDialog" :width="1200" draggable @close="closeDialog" :close-on-click-modal="false"> |
| | | <template #header> |
| | | <div style="color: #fff"> |
| | | <span>{{ state.title }}</span> |
| | | </div> |
| | | </template> |
| | | <el-card class="full-table" shadow="hover" style="margin-top: 5px"> |
| | | <el-table :data="state.tableData" @selection-change="(val: any[]) => { state.selectData = val; }" |
| | | style="width: 100%" v-loading="state.tableLoading" tooltip-effect="light" row-key="id" |
| | | @sort-change="sortChange" border> |
| | | <el-table-column type="selection" width="40" align="center" |
| | | v-if="false" /> |
| | | <!-- <el-table-column type="index" label="序号" width="55" align="center" /> --> |
| | | <el-table-column prop='exRole.name' label='交易主体' show-overflow-tooltip /> |
| | | <!-- <el-table-column prop='isManager' label='code' sortable='custom' show-overflow-tooltip > |
| | | <template #default="scope"> |
| | | <el-switch |
| | | disabled="disabled" |
| | | v-model="scope.row.isManager" |
| | | :active-value='true' |
| | | :inactive-value='false' |
| | | active-text="管理员" |
| | | inactive-text="员工" |
| | | size="small" |
| | | inline-prompt |
| | | /> |
| | | </template> |
| | | </el-table-column> --> |
| | | <el-table-column prop='exRole.code' label='code' show-overflow-tooltip /> |
| | | <el-table-column prop='steps' label='状态' v-auth="'fBS_Customer:setStatus'" show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | <el-tag :type="scope.row.steps== 2?'success':scope.row.steps== 3?'error':'primary'">{{ scope.row.steps== 2?'已通过':scope.row.steps== 3?'未通过':'审核中' }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <!-- <el-table-column prop='remark' label='备注' show-overflow-tooltip /> --> |
| | | <el-table-column label="操作" width="70" align="center" fixed="right" show-overflow-tooltip |
| | | > |
| | | <template #default="scope"> |
| | | <!-- <el-button icon="ele-Edit" size="small" text type="primary" |
| | | @click="editDialogRef.openDialog(scope.row, '编辑用户信息')" v-auth="'fBS_Customer:update'"> |
| | | </el-button> --> |
| | | <el-button icon="ele-Check" size="small" text type="primary" v-if="scope.row.steps!= 2" |
| | | @click="applyFBS_Customer(scope.row,2)" > </el-button> |
| | | <el-button icon="ele-Close" size="small" text type="primary" v-if="scope.row.steps!= 2" |
| | | @click="noFBS_Customer(scope.row,3)" > </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <ImportData ref="importDataRef" :import="fBS_CustomerApi.importData" |
| | | :download="fBS_CustomerApi.downloadTemplate" v-auth="'fBS_Customer:import'" |
| | | @refresh="handleQuery" /> |
| | | <!-- <printDialog ref="printDialogRef" :title="'打印客户表'" @reloadTable="handleQuery" /> |
| | | <editDialog ref="editDialogRef" @reloadTable="handleQuery" /> --> |
| | | </el-card> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="submit">取 消</el-button> |
| | | <el-button @click="submit" type="primary" v-reclick="1000">确 定</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | <style lang="scss" scoped> |
| | | :deep(.el-select), |
| | | :deep(.el-input-number) { |
| | | width: 100%; |
| | | } |
| | | </style> |