|
@@ -1,9 +1,136 @@
|
|
|
<template>
|
|
|
- <div class="main animate__animated animate__backInRight" v-loading="loading">满意度调查设置</div>
|
|
|
+ <div class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
+ <custom-search-bar :fields="fields.filter((f) => f.isSearch)" v-model="searchForm" @search="search" @reset="toReset"></custom-search-bar>
|
|
|
+ <custom-button-bar :fields="buttonFields" @add="toAdd"></custom-button-bar>
|
|
|
+ <custom-table :data="data" :fields="fields" @query="search" :total="total" :opera="opera" @edit="toEdit" @delete="toDelete">
|
|
|
+ <template #is_use="{ row }">
|
|
|
+ <el-tag v-if="row.is_use == '0'" type="success">启用</el-tag>
|
|
|
+ <el-tag v-else type="info">禁用</el-tag>
|
|
|
+ </template>
|
|
|
+ </custom-table>
|
|
|
+ <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose" :top="dialog.top">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" v-if="dialog.type == '1'">
|
|
|
+ <custom-form v-model="form" :fields="formFields" :rules="rules" @save="toSave">
|
|
|
+ <template #is_use>
|
|
|
+ <el-radio v-for="i in isUseList" :key="i.id" :label="i.value">{{ i.label }}</el-radio>
|
|
|
+ </template>
|
|
|
+ <template #problem>
|
|
|
+ <setTable></setTable>
|
|
|
+ </template>
|
|
|
+ <template #brief>
|
|
|
+ <WangEditor v-model="form.brief" />
|
|
|
+ </template>
|
|
|
+ </custom-form>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+const $checkRes = inject('$checkRes')
|
|
|
+import { cloneDeep, get } from 'lodash-es'
|
|
|
+const { t } = useI18n()
|
|
|
+
|
|
|
+import setTable from './parts/table.vue'
|
|
|
+
|
|
|
+// 接口
|
|
|
+import { DegreeStore } from '@/store/api/degree'
|
|
|
+import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
+const store = DegreeStore()
|
|
|
+const dictDataStore = DictDataStore()
|
|
|
+const data = ref([])
|
|
|
+const searchForm = ref({})
|
|
|
+const fields = [
|
|
|
+ { label: '标题', model: 'title' },
|
|
|
+ { label: '是否启用', model: 'is_use', format: (i) => getDict(i), custom: true }
|
|
|
+]
|
|
|
+const opera = [
|
|
|
+ { label: t('common.update'), method: 'edit' },
|
|
|
+ { label: t('common.delete'), method: 'delete', confirm: true, type: 'danger' }
|
|
|
+]
|
|
|
+const buttonFields = [{ label: t('common.add'), method: 'add' }]
|
|
|
+let skip = 0
|
|
|
+let limit = inject('limit')
|
|
|
+const total = ref(20)
|
|
|
+const isUseList = ref([])
|
|
|
// 加载中
|
|
|
const loading = ref(false)
|
|
|
+const formFields = [
|
|
|
+ { label: '标题', model: 'title' },
|
|
|
+ { label: '问题', model: 'problem', custom: true },
|
|
|
+ { label: '描述', model: 'brief', custom: true },
|
|
|
+ { label: '是否启用', model: 'is_use', type: 'radio' }
|
|
|
+]
|
|
|
+const rules = reactive({
|
|
|
+ title: [{ required: true, message: '请输入调查表标题', trigger: 'blur' }],
|
|
|
+ brief: [{ required: true, message: '请输入描述', trigger: 'blur' }],
|
|
|
+ problem: [{ required: true, message: '请输入问题', trigger: 'blur' }]
|
|
|
+})
|
|
|
+const dialog = ref({ type: '1', show: false, title: '满意度调查表', top: '15vh' })
|
|
|
+const form = ref({ problem: [] })
|
|
|
+// 请求
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true
|
|
|
+ await searchOther()
|
|
|
+ await search({ skip, limit })
|
|
|
+ loading.value = false
|
|
|
+})
|
|
|
+
|
|
|
+const searchOther = async () => {
|
|
|
+ const result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
|
|
|
+ if ($checkRes(result)) isUseList.value = result.data.data
|
|
|
+}
|
|
|
+const search = async (query = { skip: 0, limit }) => {
|
|
|
+ const info = { skip: query.skip, limit: query.limit, ...searchForm.value }
|
|
|
+ const res = await store.query(info)
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ data.value = res.data.data
|
|
|
+ total.value = res.data.total
|
|
|
+ }
|
|
|
+}
|
|
|
+// 字典数据转换
|
|
|
+const getDict = (data) => {
|
|
|
+ const res = isUseList.value.find((f) => f.value == data)
|
|
|
+ return get(res, 'label')
|
|
|
+}
|
|
|
+// 添加
|
|
|
+const toAdd = () => {
|
|
|
+ dialog.value = { type: '1', show: true, title: '新增满意度调查表', top: '15vh' }
|
|
|
+}
|
|
|
+// 修改
|
|
|
+const toEdit = (data) => {
|
|
|
+ form.value = data
|
|
|
+ dialog.value = { type: '1', show: true, title: '修改满意度调查表', top: '15vh' }
|
|
|
+}
|
|
|
+// 删除
|
|
|
+const toDelete = async (data) => {
|
|
|
+ const res = await store.del(data.id)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit })
|
|
|
+ }
|
|
|
+}
|
|
|
+const toSave = async () => {
|
|
|
+ const data = cloneDeep(form.value)
|
|
|
+ let res
|
|
|
+ if (get(data, 'id')) res = await store.update(data)
|
|
|
+ else res = await store.create(data)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+// 重置
|
|
|
+const toReset = async () => {
|
|
|
+ searchForm.value = {}
|
|
|
+ await search({ skip, limit })
|
|
|
+}
|
|
|
+const toClose = () => {
|
|
|
+ form.value = { problem: [] }
|
|
|
+ dialog.value = { show: false }
|
|
|
+}
|
|
|
+provide('form', form)
|
|
|
+provide('isUseList', isUseList)
|
|
|
</script>
|
|
|
-<style scoped></style>
|
|
|
+<style scoped lang="scss"></style>
|