| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311 |
- <template>
- <div class="supervision-review-doc-manage content-container">
- <!-- 列表视图 -->
- <div v-if="activeView === 'list'" class="list-view">
- <!-- 搜索区域 -->
- <div class="search-area">
- <el-form :inline="true" size="small">
- <!-- 文本名称输入框 -->
- <el-form-item label="文书名称:">
- <el-input
- v-model="searchForm.documentName"
- placeholder="请输入文书名称"
- clearable
- ></el-input>
- </el-form-item>
- <!-- 是否启用下拉选择 -->
- <el-form-item label="是否启用:">
- <el-select
- v-model="searchForm.status"
- placeholder="全部"
- clearable=""
- >
- <el-option label="全部" value=""></el-option>
- <el-option label="启用" value="1"></el-option>
- <el-option label="停用" value="0"></el-option>
- </el-select>
- </el-form-item>
- <!-- 搜索和重置按钮 -->
- <el-form-item>
- <el-button
- icon="iconfont-5039297 icon-chaxun"
- type="primary"
- @click="handleSearch"
- >
- 搜索
- </el-button>
- <el-button
- plain
- type="primary"
- icon="iconfont-5039297 icon-zhongzhi"
- @click="handleReset"
- >
- 重置
- </el-button>
- </el-form-item>
- </el-form>
- </div>
- <!-- 操作按钮区域 -->
- <div class="action-buttons">
- <el-button
- v-region-permission="{
- category: 'auditReviewDocManage',
- action: 'add',
- }"
- plain
- type="success"
- icon="iconfont-5039297 icon-zengjia1"
- @click="handleAdd"
- >
- 添加
- </el-button>
- <el-button
- v-region-permission="{
- category: 'auditReviewDocManage',
- action: 'delete',
- }"
- plain
- type="danger"
- icon="iconfont-5039297 icon-shanchu1"
- :disabled="selectedRows.length === 0"
- @click="handleDelete"
- >
- 删除
- </el-button>
- </div>
- <!-- 数据表格 -->
- <div class="table-container">
- <el-table
- v-loading="loading"
- :data="tableData"
- border
- style="width: 100%"
- align="center"
- @selection-change="handleSelectionChange"
- >
- <template slot="empty">
- <Empty></Empty>
- </template>
- <!-- 多选列 -->
- <el-table-column
- type="selection"
- width="55"
- show-overflow-tooltip
- align="center"
- ></el-table-column>
- <!-- 序号列 -->
- <el-table-column
- type="index"
- label="序号"
- width="60"
- show-overflow-tooltip
- align="center"
- ></el-table-column>
- <!-- 监审文书名称列 -->
- <el-table-column
- prop="documentName"
- label="监审文书名称"
- show-overflow-tooltip
- align="center"
- >
- <template slot-scope="scope">
- <div class="text-ellipsis">{{ scope.row.documentName }}</div>
- </template>
- </el-table-column>
- <!-- 别名列 -->
- <el-table-column
- prop="alias"
- label="别名"
- show-overflow-tooltip
- align="center"
- >
- <template slot-scope="scope">
- <div class="text-ellipsis">{{ scope.row.alias }}</div>
- </template>
- </el-table-column>
- <!-- 类型列 -->
- <el-table-column
- prop="type"
- label="类型"
- width="120"
- show-overflow-tooltip
- align="center"
- >
- <template slot-scope="scope">
- <span>
- {{ getDictName('documentType', scope.row.type) }}
- </span>
- </template>
- </el-table-column>
- <!-- 是否启用列(开关) -->
- <el-table-column
- prop="status"
- label="是否启用"
- width="120"
- show-overflow-tooltip
- align="center"
- >
- <template slot-scope="scope">
- <el-switch
- v-model="scope.row.status"
- v-region-permission="{
- category: 'auditReviewDocManage',
- action: 'edit',
- displayMode: 'disabled',
- }"
- active-color="#13ce66"
- active-value="1"
- inactive-value="0"
- @change="handleSwitchChange(scope.row)"
- ></el-switch>
- </template>
- </el-table-column>
- <!-- 创建人列 -->
- <el-table-column
- prop="createBy"
- label="创建人"
- width="120"
- show-overflow-tooltip
- align="center"
- ></el-table-column>
- <!-- 最后更新时间列 -->
- <el-table-column
- prop="updateTime"
- label="最后更新时间"
- width="120"
- show-overflow-tooltip
- align="center"
- >
- <template slot-scope="scope">
- <div>
- {{
- scope.row.updateTime ? scope.row.updateTime.split(' ')[0] : ''
- }}
- </div>
- <div>
- {{
- scope.row.updateTime ? scope.row.updateTime.split(' ')[1] : ''
- }}
- </div>
- </template>
- </el-table-column>
- <!-- 操作列 -->
- <el-table-column
- label="操作"
- width="180"
- show-overflow-tooltip
- align="center"
- >
- <template slot-scope="scope">
- <el-button
- v-region-permission="{
- category: 'auditReviewDocManage',
- action: 'view',
- }"
- type="text"
- size="mini"
- @click="handleDetail(scope.row)"
- >
- 详情
- </el-button>
- <el-button
- v-region-permission="{
- category: 'auditReviewDocManage',
- action: 'edit',
- }"
- type="text"
- size="mini"
- @click="handleEdit(scope.row)"
- >
- 修改
- </el-button>
- <el-button
- v-region-permission="{
- category: 'auditReviewDocManage',
- action: 'delete',
- }"
- type="text"
- size="mini"
- class="delete-btn"
- @click="handleDeleteRow(scope.row)"
- >
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 分页组件 -->
- <div class="pagination">
- <el-pagination
- :current-page="currentPage"
- :page-sizes="[50, 100]"
- :page-size="pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- ></el-pagination>
- </div>
- </div>
- <!-- 修改视图 -->
- <div v-else-if="activeView === 'edit'" class="edit-view">
- <div class="edit-header">
- <el-button plain type="primary" @click="backToList">
- <i class="iconfont-5039297 icon-fanhui"></i>
- 返回列表
- </el-button>
- </div>
- <h2 v-if="!isDisabled">
- {{ formData.id ? '修改文书模板' : '添加文书模板' }}
- </h2>
- <h2 v-else>详情</h2>
- <!-- 步骤条导航 -->
- <el-steps :active="activeStep" align-center class="steps-container">
- <el-step title="基础信息填写"></el-step>
- <el-step title="模板内容配置"></el-step>
- </el-steps>
- <!-- 步骤内容区域 -->
- <div class="step-content">
- <!-- 步骤1: 基础信息填写 -->
- <div v-if="activeStep === 0" class="form-container">
- <el-form
- ref="basicForm"
- :model="formData"
- :rules="formRules"
- label-width="120px"
- class="basic-info-form"
- :disabled="isDisabled"
- >
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form-item label="监审文书名称:" prop="documentName">
- <el-input
- v-model="formData.documentName"
- v-pinyin-abbreviation="{
- target: 'formData.alias',
- }"
- placeholder="请输入监审文书名称"
- maxlength="50"
- show-word-limit
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="监审文书别名:" prop="alias">
- <el-input
- v-model="formData.alias"
- placeholder="请输入监审文书别名"
- maxlength="50"
- show-word-limit
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form-item label="类型:" prop="type">
- <el-select
- v-model="formData.type"
- style="width: 100%"
- placeholder="请选择类型"
- >
- <el-option
- v-for="item in dictData['documentType']"
- :key="item.key"
- :label="item.name"
- :value="item.key"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="模板类型:" prop="documentType">
- <el-select
- v-model="formData.documentType"
- style="width: 100%"
- placeholder="请选择类型"
- @change="handleDocumentTypeChange"
- >
- <el-option
- v-for="item in dictData['documentTemplateType']"
- :key="item.key"
- :label="item.name"
- :value="item.key"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form-item label="是否需要文号:" prop="isWh">
- <el-radio-group v-model="formData.isWh">
- <el-radio label="0">是</el-radio>
- <el-radio label="1">否</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="说明:" prop="description">
- <el-input
- v-model="formData.description"
- type="textarea"
- placeholder="请输入说明"
- maxlength="200"
- show-word-limit
- :rows="4"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <!-- <el-form-item label="*数据来源:" prop="dataSourceType">
- <el-radio-group v-model="formData.dataSourceType">
- <el-radio label="database_table">数据库表</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item
- v-if="formData.dataSourceType === 'database_table'"
- label="数据库表:"
- prop="tableId"
- >
- <el-input
- v-model="formData.surveyTemplateName"
- style="width: 38%"
- disabled
- ></el-input>
- <el-button type="primary" @click="handleAddCostSurvey">
- 选择数据库表
- </el-button>
- <el-select
- v-model="formData.tableId"
- placeholder="请选择数据库表"
- >
- <el-option label="w_cbmx" :value="1"></el-option>
- </el-select>
- </el-form-item> -->
- </el-form>
- </div>
- <!-- 步骤2: 模板内容配置 - 左右布局 -->
- <div v-if="activeStep === 1" class="template-config-container">
- <div class="layout-wrapper">
- <!-- 左侧:上传模板和预览/修改标签页 -->
- <div class="left-panel">
- <!-- 上传模板按钮 -->
- <UploadComponent
- :upload-mode="'single'"
- :max-size="50 * 1024 * 1024"
- :allowed-types="['xlsx', 'xls', 'doc', 'docx', 'pdf']"
- :files-list="formData.fileUrl"
- action-url="/api/file/v1/tempUpload"
- button-text="上传模板"
- :is-disabled="isDisabled"
- @removeFile="removeFile"
- @saveFiles="saveFiles"
- />
- <!-- 预览/修改标签页 -->
- <template-preview-edit
- :active-tab="activeTab"
- :file-url="fileUrl"
- />
- </div>
- <!-- 右侧:数据项表格 -->
- <div class="right-panel">
- <div class="data-fields-section">
- <div class="data-fields-title">以下为数据项内容</div>
- <el-table
- :data="costDocumentTemplateFiles"
- border
- style="width: 100%"
- >
- <el-table-column prop="tableName" label="表名" align="center">
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.tableName"
- clearable
- placeholder="请输入表名(英文)"
- :disabled="isDisabled"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column prop="colName" label="列名" align="center">
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.colName"
- clearable
- placeholder="请输入列名(英文)"
- :disabled="isDisabled"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column
- prop="whereName"
- label="条件名"
- align="center"
- >
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.whereName"
- clearable
- placeholder="请输入条件名"
- :disabled="isDisabled"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column
- prop="whereValue"
- label="条件值"
- align="center"
- >
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.whereValue"
- clearable
- placeholder="请输入条件值"
- :disabled="isDisabled"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column
- prop="pinyin"
- label="拼音"
- align="center"
- width="120"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- prop="originalText"
- label="名称"
- align="center"
- width="120"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- prop="labelValue"
- label="标签"
- align="center"
- width="120"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <span>
- {{ scope.row.labelValue }}
- </span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 操作按钮区域 -->
- <div class="edit-actions">
- <el-button
- v-if="activeStep === 1"
- type="primary"
- plain
- @click="handlePrevStep"
- >
- 上一步
- </el-button>
- <el-button
- v-if="activeStep === 0"
- type="primary"
- plain
- @click="handleNextStep"
- >
- 下一步
- </el-button>
- <el-button
- v-if="!isDisabled"
- type="primary"
- plain
- style="margin-left: 20px"
- @click="handleSave"
- >
- 保存
- </el-button>
- </div>
- </div>
- <!-- 成本调查表表单 -->
- <el-dialog
- title="关联成本调查表"
- :visible.sync="costSurveyDialogVisible"
- width="50%"
- :close-on-click-modal="false"
- >
- <cost-audit-table
- :table-data="selectCostSurveyData"
- :columns="selectCostSurveyColumns"
- :show-selection="true"
- :show-pagination="true"
- :pagination="selectCostSurveyPagination"
- @pagination-change="selectCostSurveyPaginationChange"
- @selection-change="selectCostSurveySelectionChange"
- >
- <!-- 创建时间自定义单元格 -->
- <template #createTime="{ row }">
- <div>{{ row.createTime ? row.createTime.split(' ')[0] : '-' }}</div>
- <div>{{ row.createTime ? row.createTime.split(' ')[1] : '-' }}</div>
- </template>
- </cost-audit-table>
- <div slot="footer" class="dialog-footer">
- <el-button @click="costSurveyDialogVisible = false">取消</el-button>
- <el-button
- type="primary"
- @click="submitCostSurveyForm('costSurveyForm')"
- >
- 确认
- </el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import TemplatePreviewEdit from '@/components/costAudit/TemplatePreviewEdit.vue'
- import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
- import UploadComponent from '@/components/costAudit/UploadComponent.vue'
- import { dictMixin } from '@/mixins/useDict'
- import {
- getDocList,
- addDocumentTemplate,
- updateDocumentTemplate,
- batchDeleteDocumentTemplates,
- deleteDocumentTemplateById,
- queryByDocumentId,
- } from '@/api/auditReviewDocManage.js'
- import { getallCurrentCostSurveyList } from '@/api/catalogManage.js'
- export default {
- name: 'AuditReviewDocManage',
- components: {
- TemplatePreviewEdit,
- CostAuditTable,
- UploadComponent,
- },
- mixins: [dictMixin],
- data() {
- return {
- dictData: {
- documentType: [], //文书类型
- documentTemplateType: [], //文书模板类型
- },
- loading: false,
- // 视图控制
- activeView: 'list', // list: 列表视图, detail: 详情视图, edit: 修改视图
- view: 'add',
- activeDetailTab: 'basic', // 详情页标签页
- isDisabled: false,
- // 搜索表单数据
- searchForm: {
- documentName: '',
- status: '',
- },
- // 表格数据
- tableData: [],
- // 当前页码
- currentPage: 1,
- // 每页显示条数
- pageSize: 50,
- // 总记录数
- total: 0,
- // 选中的行数据
- selectedRows: [],
- costSurveyDialogVisible: false,
- selectCostSurveyData: [],
- selectCostSurveyRow: [],
- selectCostSurveyPagination: {
- currentPage: 1,
- pageSize: 10,
- total: 0,
- },
- // 表单验证规则
- formRules: {
- documentName: [
- { required: true, message: '请输入监审文书名称', trigger: 'blur' },
- {
- max: 30,
- message: '监审文书名称不能超过30个字符',
- trigger: 'blur',
- },
- ],
- alias: [
- { required: true, message: '请输入监审文书别名', trigger: 'blur' },
- {
- max: 30,
- message: '监审文书别名不能超过30个字符',
- trigger: 'blur',
- },
- ],
- documentType: [
- { required: true, message: '请选择模板类型', trigger: 'change' },
- ],
- // dataSourceType: [
- // { required: true, message: '请选择数据来源', trigger: 'change' },
- // ],
- // tableId: [
- // { required: true, message: '请选择数据表', trigger: 'change' },
- // ],
- isWh: [
- { required: true, message: '请选择是否文号', trigger: 'change' },
- ],
- type: [{ required: true, message: '请选择类型', trigger: 'change' }],
- },
- // 修改模板相关数据
- activeStep: 0, // 当前步骤,0:基础信息填写,1:模板内容配置
- activeTab: 'preview', // 当前标签页,preview:预览,edit:修改
- uploadDialogVisible: false, // 上传模板对话框显示状态
- selectedFile: null, // 选中的上传文件
- uploadedFile: null, // 已上传的文件信息
- fileContent: null, // 文件内容
- tablePreviewData: [], // 表格预览数据(前几行)
- tableColumns: [], // 表格列名
- // fileUrl:
- // window.context.form +
- // '/profile/upload/20251014/卷宗封面_20251014173930_349.docx',
- // 表单数据
- formData: {
- documentName: '',
- alias: '',
- description: '',
- isWh: '1',
- type: '',
- fileUrl: '',
- },
- // 数据项列表
- costDocumentTemplateFiles: [],
- // 详情页数据
- detailData: {},
- detailUploadedFile: null,
- detailDataFields: [],
- fileUrl: '',
- }
- },
- computed: {
- // 表格列配置
- selectCostSurveyColumns() {
- return [
- // {
- // prop: 'catalogId',
- // label: '监审类别',
- // },
- {
- prop: 'surveyTemplateName',
- label: '调查表名称',
- },
- {
- prop: 'templateType',
- label: '模版类型',
- width: '100px',
- formatter: (row) => {
- return row.templateType == '1'
- ? '单记录'
- : row.templateType == '2'
- ? '固定表'
- : '动态表'
- },
- },
- {
- prop: 'storageTable',
- label: '调查表数据存储表',
- },
- {
- prop: 'status',
- label: '状态',
- width: '100px',
- formatter: (row) => {
- return row.status == '-1'
- ? '草稿'
- : row.status == '0'
- ? '启用'
- : '停用'
- },
- },
- {
- prop: 'createTime',
- label: '创建时间',
- slotName: 'createTime',
- width: '100px',
- },
- ]
- },
- },
- created() {
- // 组件创建时加载数据
- this.handleSearch()
- },
- methods: {
- handleTabChange(tabName) {
- this.activeTab = tabName
- },
- // 搜索按钮点击事件
- async handleSearch() {
- this.loading = true
- try {
- const params = {
- ...this.searchForm,
- page: this.currentPage,
- pageSize: this.pageSize,
- }
- const response = await getDocList(params)
- this.tableData = response.value.records || []
- this.total = response.value.total || 0
- } catch (error) {
- console.log(error)
- } finally {
- this.loading = false
- }
- },
- // 重置按钮点击事件
- handleReset() {
- this.searchForm = {
- documentName: '',
- status: '',
- }
- this.currentPage = 1
- this.handleSearch()
- },
- handleAddCostSurvey() {
- this.getCostSurveyOptions()
- this.costSurveyDialogVisible = true
- },
- // 获取成本调查表选项
- getCostSurveyOptions() {
- getallCurrentCostSurveyList({}).then((res) => {
- this.selectCostSurveyData = res.value.records
- this.selectCostSurveyPagination.total = res.value.total
- })
- },
- selectCostSurveyPaginationChange({ currentPage, pageSize }) {
- this.selectCostSurveyPagination.currentPage = currentPage
- this.selectCostSurveyPagination.pageSize = pageSize
- this.getCostSurveyOptions()
- },
- selectCostSurveySelectionChange(val) {
- if (val.length > 1) {
- this.$message.warning('只能选择一个成本调查表')
- return
- }
- this.selectCostSurveyRow = val
- },
- submitCostSurveyForm() {
- if (this.selectCostSurveyRow.length == 1) {
- this.formData.tableId = this.selectCostSurveyRow[0].surveyTemplateId
- this.formData.surveyTemplateName =
- this.selectCostSurveyRow[0].surveyTemplateName
- this.costSurveyDialogVisible = false
- } else {
- this.$message.warning('请选择一个成本调查表')
- }
- },
- // 添加按钮点击事件
- handleAdd() {
- this.resetForm()
- this.activeView = 'edit'
- this.view = 'add'
- this.isDisabled = false
- },
- // 修改按钮点击事件
- async handleEdit(row) {
- this.initEditData(row)
- this.activeView = 'edit'
- this.view = 'edit'
- this.isDisabled = false
- },
- getDocumentData() {
- if (this.formData.id) {
- queryByDocumentId({ documentId: this.formData.id }).then((res) => {
- this.costDocumentTemplateFiles = res.value || []
- })
- }
- },
- // 详情按钮点击事件
- async handleDetail(row) {
- this.initEditData(row)
- this.activeView = 'edit'
- this.view = 'detail'
- this.isDisabled = true
- },
- // 返回列表
- backToList() {
- this.activeView = 'list'
- this.handleSearch()
- },
- // 初始化修改数据
- initEditData(data) {
- // 重置表单
- this.resetForm()
- // 设置表单数据
- this.formData = {}
- this.formData = {
- ...data,
- surveyTemplateName: data.tableId,
- fileUrl: data.fileUrl ? [data.fileUrl] : [],
- }
- this.fileUrl = data.fileUrl
- this.activeStep = 0
- },
- // 选中行变化事件
- handleSelectionChange(val) {
- this.selectedRows = val
- },
- // 开关状态改变事件
- async handleSwitchChange(row) {
- try {
- const response = await updateDocumentTemplate({
- ...row,
- status: row.status,
- })
- if (response.code !== 200) {
- // 回滚状态
- row.status = !row.status
- } else {
- this.$message.success('修改成功')
- this.handleSearch()
- }
- } catch (error) {
- // 回滚状态
- row.status = !row.status
- }
- },
- // 处理模板类型变化
- handleDocumentTypeChange(value) {
- // 根据选中的documentType查找对应的documentTypeName
- const documentTemplateType = this.dictData['documentTemplateType'] || []
- const selectedType = documentTemplateType.find(
- (item) => item.key === value
- )
- if (selectedType) {
- this.formData.documentTypeName = selectedType.name
- } else {
- this.formData.documentTypeName = ''
- }
- },
- // 单个删除按钮点击事件
- async handleDeleteRow(row) {
- this.$confirm('确定要删除该记录吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(async () => {
- const response = await deleteDocumentTemplateById(row.id)
- this.$message.success('删除成功')
- // 重新加载数据
- this.handleSearch()
- })
- .catch(() => {
- this.$message.info('已取消删除')
- })
- },
- // 分页大小改变事件
- handleSizeChange(val) {
- this.pageSize = val
- this.currentPage = 1
- this.handleSearch()
- },
- // 当前页改变事件
- handleCurrentChange(val) {
- this.currentPage = val
- this.handleSearch()
- },
- // 删除按钮点击事件
- async handleDelete() {
- if (this.selectedRows.length === 0) {
- this.$message.warning('请先选择要删除的记录')
- return
- }
- this.$confirm('确定要删除选中的记录吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- })
- .then(async () => {
- const ids = this.selectedRows.map((row) => row.id)
- const response = await batchDeleteDocumentTemplates({ ids })
- if (response.code === 200) {
- this.$message.success('删除成功')
- // 重新加载数据
- this.handleSearch()
- // 清空选中状态
- this.selectedRows = []
- }
- })
- .catch(() => {
- this.$message.info('已取消删除')
- })
- },
- // 复制标签到剪贴板
- copyToClipboard(tag) {
- const textarea = document.createElement('textarea')
- textarea.value = tag
- document.body.appendChild(textarea)
- textarea.select()
- document.execCommand('copy')
- document.body.removeChild(textarea)
- this.$message.success('标签已复制到剪贴板')
- },
- // 修改模板相关方法
- // 重置表单
- resetForm() {
- this.activeStep = 0
- this.formData = {
- documentName: '',
- alias: '',
- description: '',
- dataSourceType: 'database_table',
- tableId: 1,
- isWh: '1',
- type: '',
- documentType: '',
- documentTypeName: '',
- }
- this.uploadedFile = null
- this.selectedFile = null
- this.fileContent = null
- this.tablePreviewData = []
- this.tableColumns = []
- this.costDocumentTemplateFiles = []
- // 重置表单验证
- if (this.$refs.basicForm) {
- this.$refs.basicForm.resetFields()
- }
- },
- // 处理下一步
- handleNextStep() {
- this.$refs.basicForm.validate((valid) => {
- if (valid) {
- if (this.view == 'detail' || this.view == 'edit') {
- this.getDocumentData()
- this.activeStep = 1
- } else {
- this.handleSave()
- }
- } else {
- this.$message.error('请填写完整的基础信息')
- return false
- }
- })
- },
- // 处理上一步
- handlePrevStep() {
- this.activeStep = 0
- this.$message.info('返回基础信息填写')
- },
- // 处理保存
- async handleSave() {
- // 准备保存数据
- const saveData = {
- ...this.formData,
- fileUrl: this.formData.fileUrl ? this.formData.fileUrl.join(',') : '',
- costDocumentTemplateFiles:
- this.costDocumentTemplateFiles.map((item) => {
- return {
- ...item,
- documentId: this.formData.id,
- }
- }) || [],
- }
- if (this.activeStep == 1) {
- if (!this.formData.fileUrl) {
- this.$message.error('请上传文件')
- }
- }
- let response
- if (!this.formData.id) {
- // 新增
- response = await addDocumentTemplate({
- ...saveData,
- })
- this.formData.id = response.value
- } else {
- // 修改
- response = await updateDocumentTemplate({
- ...saveData,
- id: this.formData.id,
- })
- }
- if (response.code === 200) {
- this.$message.success('保存成功')
- if (this.activeStep == 1) {
- // 保存成功后返回列表
- this.backToList()
- // 重新加载数据
- this.handleSearch()
- } else {
- this.activeStep = 1
- }
- } else {
- this.$message.error(response.msg || '保存失败')
- }
- },
- // saveFiles 方法
- saveFiles(data) {
- this.formData.fileUrl = [data[0].savePath]
- this.fileUrl = data[0].savePath
- this.costDocumentTemplateFiles = data[0].bracketContentInfos.map(
- (item) => {
- return {
- ...item,
- labelValue: `{${item.pinyin}}`,
- }
- }
- )
- },
- // removeFile 方法
- removeFile(index, removedFile, currentFiles) {
- this.formData.fileUrl = []
- this.fileUrl = ''
- },
- // 下载文件
- downloadFile() {
- // 在实际项目中,这里应该调用下载API或使用文件URL直接下载
- this.$message.info('文件下载功能已触发')
- },
- },
- }
- </script>
- <style scoped lang="scss">
- @import '@/styles/costAudit.scss';
- /* 标题样式 */
- .supervision-review-doc-manage h2 {
- margin-bottom: 20px;
- font-size: 18px;
- color: #333;
- }
- /* 操作按钮区域样式 */
- .action-buttons {
- margin-bottom: 20px;
- display: flex;
- gap: 10px;
- }
- /* 表格容器样式 */
- .table-container {
- margin-bottom: 20px;
- }
- /* 分页样式 */
- .pagination {
- text-align: right;
- margin-top: 20px;
- }
- /* 操作列按钮样式调整 */
- .el-table .cell {
- white-space: normal;
- word-break: break-all;
- }
- /* 修改视图样式 */
- .edit-view,
- .detail-view {
- max-width: 100%;
- overflow-x: auto;
- }
- .edit-header,
- .detail-header {
- display: flex;
- align-items: center;
- margin-bottom: 20px;
- }
- .back-button {
- margin-right: 20px;
- }
- .steps-container {
- margin-bottom: 20px;
- }
- .step-content {
- overflow-y: auto;
- margin-bottom: 20px;
- .form-container {
- padding: 0 10px;
- }
- .template-config-container {
- .layout-wrapper {
- display: flex;
- gap: 20px;
- }
- .left-panel {
- flex: 1;
- height: 100%;
- }
- .right-panel {
- width: 50%;
- display: flex;
- flex-direction: column;
- }
- .upload-template-btn {
- margin-bottom: 20px;
- background-color: #409eff;
- border-color: #409eff;
- }
- .data-fields-section {
- flex: 1;
- display: flex;
- flex-direction: column;
- .data-fields-title {
- margin-bottom: 15px;
- padding: 10px;
- background-color: #f5f7fa;
- border-radius: 4px;
- font-size: 14px;
- color: #666;
- }
- .el-table {
- flex: 1;
- min-height: 0;
- }
- .tag-item {
- display: inline-block;
- padding: 4px 8px;
- background-color: #ecf5ff;
- color: #409eff;
- border-radius: 4px;
- font-size: 12px;
- }
- }
- }
- }
- /* 修改操作按钮区域居中显示 */
- .edit-actions {
- padding: 15px 0;
- border-top: 1px solid #e4e7ed;
- text-align: center;
- }
- .file-upload-tips {
- margin-bottom: 15px;
- padding: 10px;
- background-color: #f0f9ff;
- border: 1px solid #bae7ff;
- border-radius: 4px;
- color: #096dd9;
- font-size: 14px;
- }
- /* 修改已完成步骤的样式 */
- .el-step.is-finish {
- .el-step__head {
- /* 更改已完成步骤圆圈的背景色为白色 */
- background-color: #ffffff;
- border-color: #409eff;
- /* 修改已完成步骤的数字为√ */
- .el-step__icon-inner {
- /* 隐藏默认的数字 */
- opacity: 0;
- position: relative;
- /* 使用伪元素添加√符号 */
- &::before {
- content: '√';
- opacity: 1;
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- color: #409eff;
- font-weight: bold;
- }
- }
- }
- }
- /* 响应式设计 */
- @media (max-width: 768px) {
- .edit-header,
- .detail-header {
- flex-direction: column;
- align-items: flex-start;
- }
- .back-button {
- margin-bottom: 10px;
- }
- .template-config-container .layout-wrapper {
- flex-direction: column;
- }
- .template-config-container .right-panel {
- width: 100%;
- }
- }
- ::v-deep .el-button.is-disabled {
- background-color: #f9f9f9 !important;
- border-color: #f3f3f4 !important;
- color: #cccccc !important;
- }
- /* 文字按钮样式 */
- .el-button--text.delete-btn {
- color: #f56c6c;
- }
- </style>
|