123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <template>
- <div class="auxiliary-advice-container layout-padding">
- <div class="layout-padding-auto layout-padding-view pd20">
- <ProTable
- ref="proTableRef"
- :columns="columns"
- :data="state.tableData"
- @updateTable="queryList"
- :loading="state.loading"
- :total="state.total"
- v-model:page-index="state.queryParams.PageIndex"
- v-model:page-size="state.queryParams.PageSize"
- >
- <template #table-search>
- <el-form :model="state.queryParams" ref="ruleFormRef" inline @submit.native.prevent>
- <el-form-item label="意见类型" prop="CommonType">
- <el-select v-model="state.queryParams.CommonType" placeholder="请选择意见类型" @change="handleQuery">
- <el-option v-for="item in commonType" :value="item.key" :key="item.key" :label="item.value" />
- </el-select>
- </el-form-item>
- <el-form-item label="常用语分类" prop="isOpen">
- <el-select v-model="state.queryParams.isOpen" placeholder="请选择意见类型" @change="handleQuery">
- <el-option v-for="item in openState" :value="item.key" :key="item.key" :label="item.value" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
- <el-button @click="resetQuery(ruleFormRef)" v-waves class="default-button"> <SvgIcon name="ele-Refresh" class="mr5" />重置 </el-button>
- </el-form-item>
- </el-form>
- </template>
- <!-- 表格 header 按钮 -->
- <template #tableHeader="scope">
- <el-button type="primary" @click="onAdviceAdd"> <SvgIcon name="ele-Plus" class="mr5" />新增 </el-button>
- <el-button type="danger" @click="onAdviceDelete" :disabled="!scope.isSelected"> <SvgIcon name="ele-Delete" class="mr5" />删除<span v-if="proTableRef?.selectedList?.length">({{proTableRef?.selectedList?.length}})</span> </el-button>
- </template>
- <template #isOpen="{ row }">
- {{ row.isOpen ? '公开常用意见' : '个人常用意见' }}
- </template>
- <!-- 表格操作 -->
- <template #operation="{ row }">
- <el-button link type="primary" @click="updateAdvice(row)" v-auth="'auxiliary:advice:edit'" title="修改参数"> 修改 </el-button>
- </template>
- </ProTable>
- </div>
- <!-- 常用意见新增 -->
- <advice-add ref="adviceAddRef" @updateList="queryList" :commonType="commonType" />
- <!-- 常用意见编辑 -->
- <advice-edit ref="adviceEditRef" @updateList="queryList" :commonType="commonType" />
- </div>
- </template>
- <script lang="tsx" setup name="auxiliaryAdvice">
- import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
- import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
- import { formatDate } from '@/utils/formatTime';
- import { commonBaseData, deleteCommon, publicCommonList } from '@/api/auxiliary/advice';
- // 引入组件
- const AdviceAdd = defineAsyncComponent(() => import('@/views/auxiliary/advice/components/Advice-add.vue')); // 常用意见新增
- const AdviceEdit = defineAsyncComponent(() => import('@/views/auxiliary/advice/components/Advice-edit.vue')); // 常用意见编辑
- const proTableRef = ref<RefType>(); // 表格ref
- // 表格配置项
- const columns = ref<any[]>([
- { type: 'selection', width: 40 },
- {
- label: '意见内容',
- prop: 'content',
- minWidth: 300,
- },
- {
- label: '意见类型',
- prop: 'commonTypeText',
- minWidth: 150,
- },
- {
- label: '常用意见分类',
- prop: 'isOpen',
- minWidth: 150,
- },
- {
- label: '创建人',
- prop: 'creatorName',
- minWidth:120
- },
- {
- label: '创建部门',
- prop: 'creatorOrgName',
- minWidth:140
- },
- {
- label: '创建时间',
- prop: 'creationTime',
- width: 160,
- render: ({ row }) => {
- return <span>{formatDate(row.creationTime, 'YYYY-mm-dd HH:MM:SS')}</span>;
- },
- },
- { prop: 'operation', label: '操作', fixed: 'right', width: 80, align: 'center' },
- ]);
- // 定义变量内容
- const state = reactive({
- loading: false, // 加载状态
- queryParams: {
- // 查询参数
- PageIndex: 1,
- PageSize: 20,
- CommonType: null, // 常用意见类型
- isOpen: null, // 是否公开
- },
- total: 0, // 总条数
- tableData: [], // 表格数据
- });
- const ruleFormRef = ref<RefType>(null); // 表单ref
- const commonType = ref<EmptyArrayType>([]); // 常用意见类型
- const openState = ref<EmptyArrayType>([
- {
- key: true,
- value: '公开常用意见',
- },
- {
- key: false,
- value: '个人常用意见',
- },
- ]); // 是否公开
- const getBaseData = async () => {
- try {
- const res = await commonBaseData();
- commonType.value = res.result?.commonType ?? [];
- } catch (error) {
- console.log(error);
- }
- };
- /** 搜索按钮操作 */
- const handleQuery = () => {
- state.queryParams.PageIndex = 1;
- queryList();
- };
- // 获取列表
- const queryList = () => {
- state.loading = true;
- publicCommonList(state.queryParams)
- .then((res) => {
- state.loading = false;
- state.tableData = res.result.items ?? [];
- state.total = res.result.total ?? 0;
- })
- .finally(() => {
- state.loading = false;
- });
- };
- // 重置表单
- const resetQuery = (formEl: FormInstance | undefined) => {
- if (!formEl) return;
- formEl.resetFields();
- queryList();
- };
- // 新增意见
- const adviceAddRef = ref<RefType>(); // 意见新增
- const onAdviceAdd = () => {
- adviceAddRef.value.openDialog();
- };
- // 修改意见
- const adviceEditRef = ref<RefType>(); // 修改意见
- const updateAdvice = (row: any) => {
- adviceEditRef.value.openDialog(row);
- };
- // 删除参数
- const onAdviceDelete = () => {
- const ids = proTableRef.value.selectedList.map((item: any) => item.id);
- ElMessageBox.confirm(`您确定要删除选择的【${proTableRef.value.selectedList.length}】个常用意见,是否继续?`, '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning',
- draggable: true,
- cancelButtonClass: 'default-button',
- autofocus: false,
- })
- .then(() => {
- deleteCommon({ ids }).then(() => {
- ElMessage.success('操作成功');
- queryList();
- });
- })
- .catch(() => {});
- };
- // 页面加载时
- onMounted(() => {
- getBaseData();
- queryList();
- });
- </script>
|