|
@@ -0,0 +1,232 @@
|
|
|
+<template>
|
|
|
+ <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">
|
|
|
+ <template #field>
|
|
|
+ <el-option v-for="i in fieldList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #mature>
|
|
|
+ <el-option v-for="i in matureList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #sell>
|
|
|
+ <el-option v-for="i in sellList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </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" @exam="toExam" @edit="toEdit" @delete="toDelete">
|
|
|
+ <template #is_use="{ row }">
|
|
|
+ <el-tag v-if="row.is_use == '0'" type="success" @click="toUse(row, '1')">启用</el-tag>
|
|
|
+ <el-tag v-else type="info" @click="toUse(row, '0')">禁用</el-tag>
|
|
|
+ </template>
|
|
|
+ </custom-table>
|
|
|
+ <el-dialog v-model="dialog.show" :title="dialog.title" :destroy-on-close="false" @close="toClose">
|
|
|
+ <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 #field>
|
|
|
+ <el-option v-for="i in fieldList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #type>
|
|
|
+ <el-option v-for="i in typeList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #maturity>
|
|
|
+ <el-option v-for="i in maturityList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #skill>
|
|
|
+ <el-option v-for="i in skillList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #cooperate>
|
|
|
+ <el-option v-for="i in cooperateList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </custom-form>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" v-if="dialog.type == '2'">
|
|
|
+ <custom-form v-model="examForm" :fields="examFormFields" :rules="examRules" @save="toExamSave">
|
|
|
+ <template #status>
|
|
|
+ <el-option v-for="i in statusList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </custom-form>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+// API 引用
|
|
|
+import { getCity } from '@/utils/city'
|
|
|
+import { cloneDeep, get } from 'lodash-es'
|
|
|
+const $checkRes = inject('$checkRes')
|
|
|
+const { t } = useI18n()
|
|
|
+// 接口
|
|
|
+import { ProjectStore } from '@/store/api/platform/project'
|
|
|
+import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
+const store = ProjectStore()
|
|
|
+const dictDataStore = DictDataStore()
|
|
|
+const data = ref([])
|
|
|
+const searchForm = ref({})
|
|
|
+const fields = [
|
|
|
+ { label: t('pages.project.name'), model: 'name', isSearch: true },
|
|
|
+ { label: t('pages.project.type'), model: 'type', isSearch: true, type: 'select', format: (i) => getDict(i, 'type') },
|
|
|
+ { label: t('pages.project.field'), model: 'field', isSearch: true, type: 'select', format: (i) => getDict(i, 'field') },
|
|
|
+ { label: t('pages.project.maturity'), model: 'maturity', isSearch: true, type: 'select', format: (i) => getDict(i, 'maturity') },
|
|
|
+ { label: t('pages.project.skill'), model: 'skill', isSearch: true, type: 'select', format: (i) => getDict(i, 'skill') },
|
|
|
+ { label: t('pages.project.cooperate'), model: 'cooperate', isSearch: true, type: 'select', format: (i) => getDict(i, 'cooperate') },
|
|
|
+ { label: t('pages.project.time'), model: 'time' },
|
|
|
+ { label: t('pages.project.is_use'), model: 'is_use', custom: true, format: (i) => getDict(i, 'is_use') },
|
|
|
+ { label: t('pages.project.status'), model: 'status', format: (i) => getDict(i, 'status') }
|
|
|
+]
|
|
|
+const opera = [
|
|
|
+ { label: t('common.update'), method: 'edit', display: (i) => i.is_use === '1' },
|
|
|
+ { label: t('common.exam'), method: 'exam', type: 'warning', display: (i) => i.status === '0' },
|
|
|
+ { label: t('common.delete'), method: 'delete', confirm: true, type: 'danger', display: (i) => i.is_use === '1' }
|
|
|
+]
|
|
|
+const buttonFields = [{ label: t('common.add'), method: 'add' }]
|
|
|
+let skip = 0
|
|
|
+let limit = inject('limit')
|
|
|
+const total = ref(0)
|
|
|
+// 字典表
|
|
|
+const isUseList = ref([])
|
|
|
+const statusList = ref([])
|
|
|
+const fieldList = ref([])
|
|
|
+const typeList = ref([])
|
|
|
+const maturityList = ref([])
|
|
|
+const skillList = ref([])
|
|
|
+const cooperateList = ref([])
|
|
|
+// 加载中
|
|
|
+const loading = ref(false)
|
|
|
+const formFields = ref([
|
|
|
+ { label: t('pages.project.name'), model: 'name' },
|
|
|
+ { label: t('pages.project.type'), model: 'type', type: 'select' },
|
|
|
+ { label: t('pages.project.maturity'), model: 'maturity', type: 'select' },
|
|
|
+ { label: t('pages.project.skill'), model: 'skill', type: 'select' },
|
|
|
+ { label: t('pages.project.field'), model: 'field', type: 'select' },
|
|
|
+ { label: t('pages.project.cooperate'), model: 'cooperate', type: 'select' },
|
|
|
+ { label: t('pages.project.time'), model: 'time', type: 'date' },
|
|
|
+ { label: t('pages.project.is_use'), model: 'is_use', type: 'radio' },
|
|
|
+ { label: t('pages.project.brief'), model: 'brief', type: 'textarea' }
|
|
|
+])
|
|
|
+const rules = reactive({ name: [{ required: true, message: t('pages.project.titleMessage'), trigger: 'blur' }] })
|
|
|
+const dialog = ref({ type: '1', show: false, title: t('pages.project.addDialogTitle') })
|
|
|
+const form = ref({})
|
|
|
+// 审核
|
|
|
+const examFormFields = [{ label: t('pages.project.status'), model: 'status', type: 'select' }]
|
|
|
+const examRules = reactive({ status: [{ required: true, message: t('common.statusMessage'), trigger: 'blur' }] })
|
|
|
+const examForm = ref({})
|
|
|
+// 请求
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true
|
|
|
+ await searchOther()
|
|
|
+ await search({ skip, limit })
|
|
|
+ loading.value = false
|
|
|
+})
|
|
|
+
|
|
|
+const searchOther = async () => {
|
|
|
+ let result
|
|
|
+ // 是否使用
|
|
|
+ result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
|
|
|
+ if ($checkRes(result)) isUseList.value = result.data
|
|
|
+ // 状态
|
|
|
+ result = await dictDataStore.query({ code: 'examStatus', is_use: '0' })
|
|
|
+ if ($checkRes(result)) statusList.value = result.data
|
|
|
+ // 行业分类
|
|
|
+ result = await dictDataStore.query({ code: 'industry', is_use: '0' })
|
|
|
+ if ($checkRes(result)) typeList.value = result.data
|
|
|
+ // 成熟度
|
|
|
+ result = await dictDataStore.query({ code: 'projectMaturity', is_use: '0' })
|
|
|
+ if ($checkRes(result)) maturityList.value = result.data
|
|
|
+ // 技术领域
|
|
|
+ result = await dictDataStore.query({ code: 'field', is_use: '0' })
|
|
|
+ if ($checkRes(result)) fieldList.value = result.data
|
|
|
+ // 技术类型
|
|
|
+ result = await dictDataStore.query({ code: 'technology', is_use: '0' })
|
|
|
+ if ($checkRes(result)) skillList.value = result.data
|
|
|
+ // 合作类型
|
|
|
+ result = await dictDataStore.query({ code: 'projectType', is_use: '0' })
|
|
|
+ if ($checkRes(result)) cooperateList.value = result.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
|
|
|
+ total.value = res.total
|
|
|
+ }
|
|
|
+}
|
|
|
+// 字典数据转换
|
|
|
+const getDict = (data, model) => {
|
|
|
+ let res
|
|
|
+ if (model == 'is_use') res = isUseList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'status') res = statusList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'skill') res = skillList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'cooperate') res = cooperateList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'field') res = fieldList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'maturity') res = maturityList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'type') res = typeList.value.find((f) => f.value == data)
|
|
|
+ return get(res, 'label')
|
|
|
+}
|
|
|
+// 添加
|
|
|
+const toAdd = () => {
|
|
|
+ dialog.value = { type: '1', show: true, title: t('pages.project.addDialogTitle') }
|
|
|
+}
|
|
|
+// 修改
|
|
|
+const toEdit = (data) => {
|
|
|
+ form.value = data
|
|
|
+ dialog.value = { type: '1', show: true, title: t('pages.project.upDialogTitle') }
|
|
|
+}
|
|
|
+// 删除
|
|
|
+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)
|
|
|
+ const other = { status: '0' }
|
|
|
+ let res
|
|
|
+ if (get(data, '_id')) res = await store.update({ ...data, ...other })
|
|
|
+ else res = await store.create({ ...data, ...other })
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+// 审核
|
|
|
+const toExam = (data) => {
|
|
|
+ examForm.value = data
|
|
|
+ dialog.value = { type: '2', show: true, title: t('pages.project.examDialogTitle') }
|
|
|
+}
|
|
|
+// 审核保存
|
|
|
+const toExamSave = async () => {
|
|
|
+ const data = cloneDeep(examForm.value)
|
|
|
+ let res = await store.update(data)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+// 开启或禁用
|
|
|
+const toUse = async (data, is_use) => {
|
|
|
+ ElMessageBox.confirm(`确定修改【${data.name}】数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
|
|
|
+ .then(async () => {
|
|
|
+ let res = await store.update({ _id: get(data, '_id'), is_use })
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+}
|
|
|
+// 重置
|
|
|
+const toReset = async () => {
|
|
|
+ searchForm.value = {}
|
|
|
+ await search({ skip, limit })
|
|
|
+}
|
|
|
+const toClose = () => {
|
|
|
+ form.value = {}
|
|
|
+ dialog.value = { show: false }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style scoped lang="scss"></style>
|