|
@@ -1,11 +1,21 @@
|
|
|
<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"></custom-search-bar>
|
|
|
+ <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 #urgent>
|
|
|
+ <el-option v-for="i in urgentList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #method>
|
|
|
+ <el-option v-for="i in methodList" :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" @edit="toEdit" @delete="toDelete">
|
|
|
+ <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">启用</el-tag>
|
|
|
- <el-tag v-else type="info">禁用</el-tag>
|
|
|
+ <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">
|
|
@@ -15,6 +25,25 @@
|
|
|
<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 #urgent>
|
|
|
+ <el-option v-for="i in urgentList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #method>
|
|
|
+ <el-option v-for="i in methodList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #area>
|
|
|
+ <el-cascader v-model="form.area" :props="{ value: 'name', label: 'name' }" :options="cityList" @change="handleChange" style="width: 100%" />
|
|
|
+ </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>
|
|
@@ -23,6 +52,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+// API 引用
|
|
|
+import { getCity } from '@/utils/city'
|
|
|
import { cloneDeep, get } from 'lodash-es'
|
|
|
const $checkRes = inject('$checkRes')
|
|
|
const { t } = useI18n()
|
|
@@ -35,21 +66,31 @@ const data = ref([])
|
|
|
const searchForm = ref({})
|
|
|
const fields = [
|
|
|
{ label: t('pages.demand.name'), model: 'name', isSearch: true },
|
|
|
- { label: t('pages.demand.field'), model: 'field', isSearch: true },
|
|
|
- { label: t('pages.demand.urgent'), model: 'urgent', isSearch: true },
|
|
|
- { label: t('pages.demand.method'), model: 'method' },
|
|
|
+ { label: t('pages.demand.field'), model: 'field', isSearch: true, type: 'select', format: (i) => getDict(i, 'field') },
|
|
|
+ { label: t('pages.demand.urgent'), model: 'urgent', isSearch: true, type: 'select', format: (i) => getDict(i, 'urgent') },
|
|
|
+ { label: t('pages.demand.method'), model: 'method', isSearch: true, type: 'select', format: (i) => getDict(i, 'method') },
|
|
|
{ label: t('pages.demand.money'), model: 'money' },
|
|
|
- { label: t('pages.demand.is_use'), model: 'is_use', custom: true, format: (i) => getDict(i) }
|
|
|
+ { label: t('pages.demand.is_use'), model: 'is_use', custom: true, format: (i) => getDict(i, 'is_use') },
|
|
|
+ { label: t('pages.demand.demand_status'), model: 'demand_status', format: (i) => getDict(i, 'demand') },
|
|
|
+ { label: t('pages.demand.status'), model: 'status', format: (i) => getDict(i, 'status') }
|
|
|
]
|
|
|
const opera = [
|
|
|
- { label: t('common.update'), method: 'edit' },
|
|
|
- { label: t('common.delete'), method: 'delete', confirm: true, type: 'danger' }
|
|
|
+ { 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(20)
|
|
|
+// 字典表
|
|
|
const isUseList = ref([])
|
|
|
+const statusList = ref([])
|
|
|
+const methodList = ref([])
|
|
|
+const urgentList = ref([])
|
|
|
+const fieldList = ref([])
|
|
|
+const cityList = ref([])
|
|
|
+const demandList = ref([])
|
|
|
// 加载中
|
|
|
const loading = ref(false)
|
|
|
const formFields = ref([
|
|
@@ -58,8 +99,7 @@ const formFields = ref([
|
|
|
{ label: t('pages.demand.urgent'), model: 'urgent', type: 'select' },
|
|
|
{ label: t('pages.demand.method'), model: 'method', type: 'select' },
|
|
|
{ label: t('pages.demand.money'), model: 'money' },
|
|
|
- { label: t('pages.demand.province'), model: 'province' },
|
|
|
- { label: t('pages.demand.city'), model: 'city' },
|
|
|
+ { label: t('pages.demand.area'), model: 'area', custom: true },
|
|
|
{ label: t('pages.demand.time'), model: 'time', type: 'daterange' },
|
|
|
{ label: t('pages.demand.is_use'), model: 'is_use', type: 'radio' },
|
|
|
{ label: t('pages.demand.brief'), model: 'brief', type: 'textarea' }
|
|
@@ -67,17 +107,41 @@ const formFields = ref([
|
|
|
const rules = reactive({ name: [{ required: true, message: t('pages.demand.titleMessage'), trigger: 'blur' }] })
|
|
|
const dialog = ref({ type: '1', show: false, title: t('pages.demand.addDialogTitle') })
|
|
|
const form = ref({})
|
|
|
+// 审核
|
|
|
+const examFormFields = [{ label: t('pages.demand.status'), model: 'status', type: 'select' }]
|
|
|
+const examRules = reactive({ title: [{ required: true, message: t('pages.demand.titleMessage'), trigger: 'blur' }] })
|
|
|
+const examForm = ref({})
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
loading.value = true
|
|
|
+ getCity().then((response) => {
|
|
|
+ cityList.value = response.address
|
|
|
+ })
|
|
|
await searchOther()
|
|
|
await search({ skip, limit })
|
|
|
loading.value = false
|
|
|
})
|
|
|
|
|
|
const searchOther = async () => {
|
|
|
- const result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
|
|
|
+ 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: 'method', is_use: '0' })
|
|
|
+ if ($checkRes(result)) methodList.value = result.data
|
|
|
+ // 需求紧急度
|
|
|
+ result = await dictDataStore.query({ code: 'urgent', is_use: '0' })
|
|
|
+ if ($checkRes(result)) urgentList.value = result.data
|
|
|
+ // 技术领域
|
|
|
+ result = await dictDataStore.query({ code: 'field', is_use: '0' })
|
|
|
+ if ($checkRes(result)) fieldList.value = result.data
|
|
|
+ // 需求状态
|
|
|
+ result = await dictDataStore.query({ code: 'demandStatus', is_use: '0' })
|
|
|
+ if ($checkRes(result)) demandList.value = result.data
|
|
|
}
|
|
|
const search = async (query = { skip: 0, limit }) => {
|
|
|
const info = { skip: query.skip, limit: query.limit, ...searchForm.value, type: '0' }
|
|
@@ -88,8 +152,14 @@ const search = async (query = { skip: 0, limit }) => {
|
|
|
}
|
|
|
}
|
|
|
// 字典数据转换
|
|
|
-const getDict = (data) => {
|
|
|
- const res = isUseList.value.find((f) => f.value == data)
|
|
|
+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 == 'method') res = methodList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'urgent') res = urgentList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'field') res = fieldList.value.find((f) => f.value == data)
|
|
|
+ else if (model == 'demand') res = demandList.value.find((f) => f.value == data)
|
|
|
return get(res, 'label')
|
|
|
}
|
|
|
// 添加
|
|
@@ -111,14 +181,36 @@ const toDelete = async (data) => {
|
|
|
}
|
|
|
const toSave = async () => {
|
|
|
const data = cloneDeep(form.value)
|
|
|
+ const other = { status: '0' }
|
|
|
let res
|
|
|
- if (get(data, '_id')) res = await store.update(data)
|
|
|
- else res = await store.create(data)
|
|
|
+ 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.demand.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) => {
|
|
|
+ let res = await store.update({ _id: get(data, '_id'), is_use })
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit })
|
|
|
+ }
|
|
|
+}
|
|
|
// 重置
|
|
|
const toReset = async () => {
|
|
|
searchForm.value = {}
|