123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- import { reactive, onMounted, ref, ElMessage, ElMessageBox, http, getGroupUrl, RegularVerification, verification, PaginationProps } from "@/utils/importUsed"
- // 表单实例
- const ruleFormRef = ref()
- export function useFileUpdateInfo() {
- // 接口列表实例
- let UrlList = reactive(null)
- // 获取当前板块接口列表
- onMounted(async () => {
- UrlList = await getGroupUrl(["kxsConfigServer"]);
- onSearch(ruleFormRef.value);
- });
- let form = reactive({
- kind: "", //分类
- });
- const dataList = ref([]);
- const loading = ref(false);
- const dialogAddVisible = ref(false);
- const pagination = reactive<PaginationProps>({
- total: 0,
- pageSize: 10,
- currentPage: 1,
- background: true
- });
- const columns: TableColumnList = [
- {
- type: "selection",
- width: 55,
- align: "left",
- hide: ({ checkList }) => !checkList.includes("勾选列")
- },
- {
- label: "序号",
- type: "index",
- width: 70,
- hide: ({ checkList }) => !checkList.includes("序号列")
- },
- {
- label: "ID",
- prop: "id",
- minWidth: 200
- },
- {
- label: "更新版本",
- prop: "versionNum",
- minWidth: 200
- },
- {
- label: "路径",
- prop: "path",
- minWidth: 200
- },
- {
- label: "文件名",
- prop: "fileName",
- minWidth: 200
- },
- {
- label: "操作",
- fixed: "right",
- width: 200,
- slot: "operation"
- }
- ];
- // 当前页数量切换
- function handleSizeChange(val: number) {
- if (typeof val === "number") {
- pagination.pageSize = val;
- onSearch(ruleFormRef.value);
- }
- }
- // 当前页码切换
- function handleCurrentChange(val: number) {
- console.log(`current page: ${val}`);
- if (typeof val === "number") {
- pagination.currentPage = val;
- onSearch(ruleFormRef.value);
- }
- }
- // 选择表格项
- function handleSelectionChange(val) {
- console.log(`SelectionChange: ${val}`);
- onSearch(ruleFormRef.value);
- }
- // 搜索列表
- async function onSearch(formEl) {
- // 表单校验拦截
- if (!formEl) return
- await formEl.validate(async (valid, fields) => {
- if (valid) {
- //表单校验成功回调
- console.log('submit!')
- // 状态调整为加载中
- loading.value = true;
- // 调用接口(需动态生成接口)
- const { status, msg, data }: any = await http.Request({
- method: UrlList.kxsConfigServer.fileUpdateInfolist.method,
- url: UrlList.kxsConfigServer.fileUpdateInfolist.url,
- params: {
- ...form,
- pageSize: pagination.pageSize,
- pageNum: pagination.currentPage
- }
- });
- dataList.value = data.records;
- pagination.total = data.total;
- setTimeout(() => {
- loading.value = false;
- }, 500);
- } else {
- //表单校验失败回调
- ElMessage({
- message: "请输入完整信息",
- type: "error"
- });
- }
- })
- }
- // 删除
- function handleDelete(row) {
- ElMessageBox.confirm(
- `是否删除该资源文件更新信息? `,
- "提示",
- {
- confirmButtonText: "删除",
- cancelButtonText: "取消",
- type: "warning"
- }
- ).then(async () => {
- const { status, msg }: any = await http.Request({ method: UrlList.kxsConfigServer.fileUpdateInfodelete.method, url: UrlList.kxsConfigServer.fileUpdateInfodelete.url, params: String(row.id) });
- if (status === 1) {
- ElMessage({
- message: "删除成功",
- type: "success"
- });
- onSearch(ruleFormRef.value);
- } else {
- ElMessageBox.alert(msg, "提示", {
- confirmButtonText: "关闭",
- type: "warning"
- });
- };
- })
- }
- function handleSycn() {
- if (form.kind == "") {
- ElMessageBox.alert("请筛选分类", "提示", {
- confirmButtonText: "关闭",
- type: "warning"
- });
- return;
- }
- ElMessageBox.confirm(
- `是否同步资源文件? `,
- "提示",
- {
- confirmButtonText: "同步",
- cancelButtonText: "取消",
- type: "warning"
- }
- ).then(async () => {
- const { status, msg }: any = await http.Request({ method: UrlList.kxsConfigServer.fileUpdateInfoupdateFile.method, url: UrlList.kxsConfigServer.fileUpdateInfoupdateFile.url, params: { kind: form.kind } });
- if (status === 1) {
- ElMessage({
- message: "同步成功",
- type: "success"
- });
- onSearch(ruleFormRef.value);
- } else {
- ElMessageBox.alert(msg, "提示", {
- confirmButtonText: "关闭",
- type: "warning"
- });
- };
- })
- }
- // 新增
- const addVisible = ref(false);
- function handleAdd() {
- addVisible.value = true;
- };
- // 修改
- const editUpdateVisible = ref(false);
- const editUpdateFormData = ref({});
- function handleUpdate(row) {
- editUpdateVisible.value = true;
- // 表格数据赋值
- editUpdateFormData.value = row;
- };
- // 更新版本号
- const editUpVersionVisible = ref(false);
- const editUpVersionFormData = ref({});
- function handleUpVersion(row) {
- editUpVersionVisible.value = true;
- // 表格数据赋值
- editUpVersionFormData.value = row;
- };
- return {
- form,
- loading,
- columns,
- dataList,
- pagination,
- onSearch,
- handleSizeChange,
- handleCurrentChange,
- handleSelectionChange,
- ruleFormRef,
- handleAdd,
- addVisible,
- handleUpdate,
- editUpdateVisible,
- editUpdateFormData,
- handleDelete,
- handleUpVersion,
- handleSycn,
- editUpVersionVisible,
- editUpVersionFormData,
- };
- }
|