|
@@ -5,6 +5,7 @@
|
|
|
<el-option v-for="i in sectorList" :key="i.id" :label="i.title" :value="i.title"></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" @view="toView" @exam="toExam" @delete="toDelete">
|
|
|
<template #role="{ row }">
|
|
|
<div class="tags">
|
|
@@ -42,6 +43,19 @@
|
|
|
</template>
|
|
|
</custom-form>
|
|
|
</el-col>
|
|
|
+ <el-col :span="24" v-if="dialog.type == '3'">
|
|
|
+ <custom-form v-model="form" :fields="formFields" @save="toSave">
|
|
|
+ <template #role>
|
|
|
+ <el-checkbox v-for="i in roleList" :key="i.code" :label="i.name" :value="i.code" />
|
|
|
+ </template>
|
|
|
+ <template #industry>
|
|
|
+ <el-checkbox v-for="i in sectorList" :key="i.id" :label="i.title" :value="i.title" />
|
|
|
+ </template>
|
|
|
+ <template #gender>
|
|
|
+ <el-option v-for="i in genderList" :key="i.id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </custom-form>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
@@ -125,6 +139,7 @@ const opera = [
|
|
|
type: 'danger'
|
|
|
}
|
|
|
]
|
|
|
+const buttonFields = [{ label: t('common.create'), method: 'add' }]
|
|
|
const searchForm = ref({})
|
|
|
const dialog = ref({ type: '1', show: false, title: t('pages.user.dialogTitle') })
|
|
|
// 查询
|
|
@@ -138,6 +153,16 @@ const search = async (query = { skip, limit }) => {
|
|
|
total.value = res.total
|
|
|
}
|
|
|
}
|
|
|
+const formFields = ref([
|
|
|
+ { label: t('pages.user.account'), model: 'account' },
|
|
|
+ { label: t('pages.user.password'), model: 'password', type: 'password' },
|
|
|
+ { label: t('pages.user.nick_name'), model: 'nick_name' },
|
|
|
+ { label: t('pages.user.role'), model: 'role', type: 'checkbox' },
|
|
|
+ { label: t('pages.user.industry'), model: 'industry', type: 'checkbox' },
|
|
|
+ { label: t('pages.user.gender'), model: 'gender', type: 'select' },
|
|
|
+ { label: t('pages.user.email'), model: 'email' },
|
|
|
+ { label: t('pages.user.phone'), model: 'phone' }
|
|
|
+])
|
|
|
// 表单验证
|
|
|
const ruleFormRef = ref()
|
|
|
const form = ref({})
|
|
@@ -171,9 +196,6 @@ const searchOther = async () => {
|
|
|
// 性别
|
|
|
result = await dictDataStore.query({ code: 'gender', is_use: '0' })
|
|
|
if ($checkRes(result)) genderList.value = result.data
|
|
|
- // 角色
|
|
|
- result = await roleStore.query({ is_use: '0' })
|
|
|
- if ($checkRes(result)) roleList.value = result.data
|
|
|
// 专家领域
|
|
|
result = await dictDataStore.query({ code: 'field', is_use: '0' })
|
|
|
if ($checkRes(result)) fieldList.value = result.data
|
|
@@ -202,7 +224,7 @@ const searchOther = async () => {
|
|
|
result = await regionStore.area({ level: 'province', code: 22 })
|
|
|
if ($checkRes(result)) cityList.value = result.data
|
|
|
// 角色
|
|
|
- result = await roleStore.query({ is_use: '0' })
|
|
|
+ result = await roleStore.query({ is_use: '0', is_admin_role: '0' })
|
|
|
if ($checkRes(result)) roleList.value = result.data
|
|
|
// 行业
|
|
|
result = await sectorStore.query({ is_use: '0' })
|
|
@@ -233,11 +255,15 @@ const getDict = (data, model) => {
|
|
|
return get(res, 'label')
|
|
|
}
|
|
|
}
|
|
|
+const toAdd = () => {
|
|
|
+ form.value = { role: ['User'] }
|
|
|
+ dialog.value = { type: '3', show: true, title: t('pages.user.addDialogTitle') }
|
|
|
+}
|
|
|
// 查看
|
|
|
const toView = async (data) => {
|
|
|
form.value = data
|
|
|
- user_id.value = data.id
|
|
|
role.value = get(data, 'role')
|
|
|
+ user_id.value = data.id
|
|
|
dialog.value = { type: '1', show: true, title: t('pages.user.dialogTitle') }
|
|
|
}
|
|
|
// 标签改变
|
|
@@ -301,6 +327,16 @@ const toExamSave = async () => {
|
|
|
toClose()
|
|
|
}
|
|
|
}
|
|
|
+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, limit })
|
|
|
+ toClose()
|
|
|
+ }
|
|
|
+}
|
|
|
const toClose = () => {
|
|
|
form.value = {}
|
|
|
type.value = 'User'
|
|
@@ -331,8 +367,7 @@ provide('IndustryList', IndustryList)
|
|
|
provide('cardTypeList', cardTypeList)
|
|
|
provide('contributionList', contributionList)
|
|
|
provide('modeList', modeList)
|
|
|
-// 方法
|
|
|
-provide('getRole', getRole)
|
|
|
+provide('roleList', roleList)
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|
|
|
.tags {
|