zhangwei
2025-08-29 161355f01e267159f065ec0b277c6735437b1eab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<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>