|
@@ -1,6 +1,10 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <CtFilter :items="filterItems" @reset="handleReset" @search="handleSearch" />
|
|
|
+ <CtFilter :items="filterItems" @reset="handleReset" @search="handleSearch">
|
|
|
+ <template #appendBtn>
|
|
|
+ <v-btn class="ml-3" elevation="5" color="primary" prepend-icon="mdi-plus" @click="handleAdd">新增</v-btn>
|
|
|
+ </template>
|
|
|
+ </CtFilter>
|
|
|
|
|
|
<v-card elevation="5" class="mt-3">
|
|
|
<CtTable
|
|
@@ -10,77 +14,81 @@
|
|
|
:loading="loading"
|
|
|
:disable-sort="true"
|
|
|
:elevation="0"
|
|
|
- :isTools="true"
|
|
|
- height="calc(100vh - 400px)"
|
|
|
- :showPage="true"
|
|
|
+ :items-per-page="-1"
|
|
|
+ :isTools="false"
|
|
|
+ height="70vh"
|
|
|
+ :showPage="false"
|
|
|
:showFixedLastItem="true"
|
|
|
- :total="total"
|
|
|
- :pageInfo="query"
|
|
|
itemKey="id"
|
|
|
- @pageHandleChange="handleChangePage"
|
|
|
- @add="handle"
|
|
|
>
|
|
|
+ <template #en_name="{ item }">
|
|
|
+ <div v-ellipse-tooltip style="max-width: 250px;">{{ item.en_name }}</div>
|
|
|
+ </template>
|
|
|
+ <template #description="{ item }">
|
|
|
+ <div v-ellipse-tooltip style="max-width: 250px;">{{ item.description }}</div>
|
|
|
+ </template>
|
|
|
+ <template #status="{ item }">
|
|
|
+ <span :class="`color-${item.status === 'active' ? 'primary' : 'error'}`">
|
|
|
+ {{ item.status === 'active' ? '启用' : '禁用' }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
<template #actions="{ item }">
|
|
|
- <v-btn variant="text" color="primary" @click.stop="handle(1, item)">编 辑</v-btn>
|
|
|
- <v-btn variant="text" color="warning" @click.stop="handle(2, item)">禁 用</v-btn>
|
|
|
- <v-btn variant="text" color="error" @click.stop="handle(3, item)">删 除</v-btn>
|
|
|
+ <v-btn variant="text" color="primary" @click.stop="handleEdit(item)">编 辑</v-btn>
|
|
|
+ <v-btn variant="text" color="error" @click.stop="handleDelete(item)">删 除</v-btn>
|
|
|
</template>
|
|
|
</CtTable>
|
|
|
</v-card>
|
|
|
|
|
|
- <!-- <v-navigation-drawer v-model="dialog" absolute location="right" rounded temporary width="700" class="pa-5">
|
|
|
- </v-navigation-drawer> -->
|
|
|
-
|
|
|
- <CtDialog :visible="dialog" :widthType="4" :footer="true" titleClass="text-h6" :title="title" @submit="handleSubmit" @close="dialog = false">
|
|
|
- <CtForm ref="formPageRef" :items="formItems">
|
|
|
- </CtForm>
|
|
|
+ <CtDialog
|
|
|
+ :visible="showDialog"
|
|
|
+ :widthType="4"
|
|
|
+ :footer="true"
|
|
|
+ titleClass="text-h6"
|
|
|
+ :title="type === 'add' ? '新增' : '编辑'"
|
|
|
+ @submit="handleSubmit" @close="handleClose"
|
|
|
+ >
|
|
|
+ <CtForm ref="formPageRef" :items="formItems" />
|
|
|
</CtDialog>
|
|
|
-
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
defineOptions({ name: 'newTalentMapTag'})
|
|
|
import { ref } from 'vue'
|
|
|
-import { getNewAppointmentsPage } from '@/api/recruit/enterprise/newlyAppointed'
|
|
|
import Snackbar from '@/plugins/snackbar'
|
|
|
import Confirm from '@/plugins/confirm'
|
|
|
-import { timesTampChange } from '@/utils/date'
|
|
|
+import _ from 'lodash'
|
|
|
+import { getTalentTagList, deleteTalentTag, createTalentTag, updateTalentTag } from '@/api/recruit/enterprise/talentMap/tag'
|
|
|
|
|
|
const loading = ref(false)
|
|
|
-const total = ref(10)
|
|
|
-const query = ref({
|
|
|
- pageSize: 10,
|
|
|
- pageNo: 1
|
|
|
-})
|
|
|
-const items = ref([])
|
|
|
+const query = ref({})
|
|
|
+const formPageRef = ref()
|
|
|
+const items = ref( [])
|
|
|
const headers = [
|
|
|
- { title: '标签名称', key: 'announceTime', sortable: false },
|
|
|
- { title: '标签分类', key: 'nameChinese', sortable: false },
|
|
|
- { title: '描述', key: 'introduce', sortable: false },
|
|
|
+ { title: '标签名称', key: 'name', sortable: false },
|
|
|
+ { title: '标签英文名称', key: 'en_name', sortable: false },
|
|
|
+ { title: '标签分类', key: 'category', sortable: false },
|
|
|
+ { title: '标签描述', key: 'description', sortable: false },
|
|
|
{ title: '标签状态', key: 'status', sortable: false },
|
|
|
- { title: '创建时间', key: 'createTimeTamp', sortable: false },
|
|
|
- { title: '创建人', key: 'createPerson', sortable: false },
|
|
|
- { title: '更新时间', key: 'updateTimeTamp', sortable: false },
|
|
|
- { title: '修改人', key: 'updatePerson', sortable: false },
|
|
|
+ { title: '更新时间', key: 'time', sortable: false },
|
|
|
{ title: '操作', key: 'actions', sortable: false, align: 'center' }
|
|
|
]
|
|
|
const filterItems = ref({
|
|
|
options: [
|
|
|
- {
|
|
|
+ {
|
|
|
type: 'text',
|
|
|
- key: 'nameChinese',
|
|
|
+ key: 'name',
|
|
|
value: '',
|
|
|
- label: '标签分类',
|
|
|
+ label: '标签名称',
|
|
|
clearable: true,
|
|
|
hideDetails: true,
|
|
|
width: 200
|
|
|
},
|
|
|
{
|
|
|
type: 'text',
|
|
|
- key: 'nameEnglish',
|
|
|
+ key: 'category',
|
|
|
value: '',
|
|
|
- label: '标签名称',
|
|
|
+ label: '标签分类',
|
|
|
clearable: true,
|
|
|
hideDetails: true,
|
|
|
width: 200
|
|
@@ -93,8 +101,8 @@ const filterItems = ref({
|
|
|
clearable: true,
|
|
|
hideDetails: true,
|
|
|
width: 200,
|
|
|
- items: [{label: '禁用', value: '禁用'}, {label: '启用', value: '启用'}]
|
|
|
- },
|
|
|
+ items: [{ label: '禁用', value: 'disable' }, { label: '启用', value: 'active' }]
|
|
|
+ }
|
|
|
]
|
|
|
})
|
|
|
|
|
@@ -102,165 +110,138 @@ const formItems = ref({
|
|
|
options: [
|
|
|
{
|
|
|
type: 'text',
|
|
|
- key: 'announceTime',
|
|
|
+ key: 'name',
|
|
|
value: '',
|
|
|
label: '标签名称 *',
|
|
|
rules: [v => !!v || '请输入标签名称']
|
|
|
},
|
|
|
{
|
|
|
type: 'text',
|
|
|
- key: 'nameChinese',
|
|
|
- value: '',
|
|
|
- label: '标签分类 *',
|
|
|
- rules: [v => !!v || '请输入标签分类']
|
|
|
+ key: 'category',
|
|
|
+ value: '人才',
|
|
|
+ defaultValue: '人才',
|
|
|
+ disabled: true,
|
|
|
+ label: '标签分类'
|
|
|
},
|
|
|
{
|
|
|
type: 'textarea',
|
|
|
- key: 'introduce',
|
|
|
+ key: 'description',
|
|
|
value: null,
|
|
|
counter: 2000,
|
|
|
- rows: 2,
|
|
|
+ rows: 3,
|
|
|
label: '描述',
|
|
|
outlined: true
|
|
|
},
|
|
|
{
|
|
|
type: 'ifRadio',
|
|
|
- key: 'type',
|
|
|
- value: '0',
|
|
|
- default: '0',
|
|
|
- label: '是否启用 *',
|
|
|
+ key: 'status',
|
|
|
+ value: 'active',
|
|
|
+ defaultValue: 'active',
|
|
|
+ label: '标签状态 *',
|
|
|
width: 90,
|
|
|
items: [
|
|
|
- { label: '启用', value: '0' },
|
|
|
- { label: '禁用', value: '1' }
|
|
|
+ { label: '启用', value: 'active' },
|
|
|
+ { label: '禁用', value: 'disable' }
|
|
|
]
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- key: 'createTimeTamp',
|
|
|
- value: '',
|
|
|
- label: '创建时间',
|
|
|
- noParam: true,
|
|
|
- disabled: true,
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- key: 'createPerson',
|
|
|
- value: '',
|
|
|
- label: '创建人',
|
|
|
- noParam: true,
|
|
|
- disabled: true,
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- key: 'updateTimeTamp',
|
|
|
- value: '',
|
|
|
- label: '修改时间',
|
|
|
- noParam: true,
|
|
|
- disabled: true,
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- key: 'updatePerson',
|
|
|
- value: '',
|
|
|
- label: '修改人',
|
|
|
- noParam: true,
|
|
|
- disabled: true,
|
|
|
- },
|
|
|
+ }
|
|
|
]
|
|
|
})
|
|
|
|
|
|
-// 获取新任命分页
|
|
|
+// 获取人才标签列表
|
|
|
const getList = async () => {
|
|
|
loading.value = true
|
|
|
try {
|
|
|
- const result = await getNewAppointmentsPage(query.value)
|
|
|
- items.value = result?.list?.map(e => {
|
|
|
- const res = {
|
|
|
- createTimeTamp: e.createTime ? timesTampChange(e.createTime) : null,
|
|
|
- updateTimeTamp: e.updateTime ? timesTampChange(e.updateTime) : null,
|
|
|
- ...e
|
|
|
- }
|
|
|
- return res
|
|
|
- })
|
|
|
- console.log('items:', items.value)
|
|
|
- total.value = result.total
|
|
|
+ const data = await getTalentTagList()
|
|
|
+ items.value = data || []
|
|
|
} finally {
|
|
|
loading.value = false
|
|
|
}
|
|
|
}
|
|
|
getList()
|
|
|
|
|
|
-// 分页切换
|
|
|
-const handleChangePage = async (e) => {
|
|
|
- query.value.pageNo = e
|
|
|
- getList()
|
|
|
-}
|
|
|
-
|
|
|
// 搜索
|
|
|
const handleSearch = async (obj) => {
|
|
|
- query.value = Object.assign(query.value, obj)
|
|
|
- query.value.pageNo = 1
|
|
|
+ query.value = obj
|
|
|
getList()
|
|
|
}
|
|
|
// 重置
|
|
|
const handleReset = (obj) => {
|
|
|
- query.value = Object.assign(query.value, obj)
|
|
|
- query.value.pageNo = 1
|
|
|
+ query.value = obj
|
|
|
getList()
|
|
|
}
|
|
|
|
|
|
const getValue = () => {
|
|
|
return formItems.value.options.reduce((res, item) => {
|
|
|
- if (!e.noParam) res[item.key] = item.value
|
|
|
+ // if (!item.noParam) res[item.key] = item.value
|
|
|
+ res[item.key] = item.value
|
|
|
return res
|
|
|
}, {})
|
|
|
}
|
|
|
|
|
|
-const handleSubmit = async () => {
|
|
|
- const { valid } = await formPageRef.value.formRef.validate()
|
|
|
- if (!valid) return
|
|
|
- const obj = getValue()
|
|
|
- if (itemObj.value) obj.id = itemObj.value.id
|
|
|
- await getNewAppointmentsPage(obj)
|
|
|
- Snackbar.success(`${title.value}成功`)
|
|
|
-}
|
|
|
-
|
|
|
const setValue = (item) => {
|
|
|
formItems.value.options.forEach(e => {
|
|
|
e.value = item ? item[e.key] || null : e.default || null
|
|
|
- e.hide = !item && e.noParam ? true : false
|
|
|
+ // e.hide = !item && e.noParam ? true : false
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const title = ref('')
|
|
|
-const itemObj = ref(null)
|
|
|
-const dialog = ref(false)
|
|
|
-const handle = async (index, item) => {
|
|
|
- if (index === 1) {
|
|
|
- title.value = '编辑'
|
|
|
- itemObj.value = item
|
|
|
- setValue(item)
|
|
|
- } else if (index === 2 || index === 3) {
|
|
|
- // 禁用 // 删除
|
|
|
- const del = Boolean(index === 3)
|
|
|
- const tagTxt = item?.title ? `【${item.title}】` : '此'
|
|
|
- const text = del ? `是否确认删除${tagTxt}标签?` : `是否确认禁用${tagTxt}标签?`
|
|
|
- const api = del ? getNewAppointmentsPage : getNewAppointmentsPage
|
|
|
- Confirm('系统提示', text).then(async () => {
|
|
|
- if (!e?.id) return Snackbar.error('数据错误请刷新重试!')
|
|
|
- await api(e.id)
|
|
|
- Snackbar.success(del ? '删除成功!' : '禁用标签成功!')
|
|
|
- getList()
|
|
|
- })
|
|
|
- return
|
|
|
- } else {
|
|
|
- title.value = '新增'
|
|
|
- setValue(item)
|
|
|
- }
|
|
|
- dialog.value = true
|
|
|
+const type = ref('add')
|
|
|
+const editId = ref(null)
|
|
|
+const editItemData = ref({})
|
|
|
+const showDialog = ref(false)
|
|
|
+
|
|
|
+// 删除标签
|
|
|
+const handleDelete = async (item) => {
|
|
|
+ if (!item?.id) return Snackbar.warning('数据错误请刷新重试!')
|
|
|
+ Confirm('系统提示', `是否确认删除【${item.name}】标签?`).then(async () => {
|
|
|
+ await deleteTalentTag(item.id)
|
|
|
+ Snackbar.success('删除成功!')
|
|
|
+ getList()
|
|
|
+ }).catch(() => {})
|
|
|
+}
|
|
|
+
|
|
|
+// 新增
|
|
|
+const handleAdd = () => {
|
|
|
+ type.value = 'add'
|
|
|
+ formItems.value.options.forEach(e => e.value = e?.defaultValue || null)
|
|
|
+ showDialog.value = true
|
|
|
+}
|
|
|
+
|
|
|
+// 编辑
|
|
|
+const valueKeys = ['name', 'category', 'status', 'description']
|
|
|
+const handleEdit = async (item) => {
|
|
|
+ type.value = 'edit'
|
|
|
+ editId.value = item.id
|
|
|
+ valueKeys.forEach(key => editItemData.value[key] = item[key])
|
|
|
+ setValue(item)
|
|
|
+ showDialog.value = true
|
|
|
+}
|
|
|
+
|
|
|
+const handleClose = () => {
|
|
|
+ showDialog.value = false
|
|
|
+ editItemData.value = {}
|
|
|
+ editId.value = null
|
|
|
}
|
|
|
|
|
|
+// 新增/编辑-提交
|
|
|
+const handleSubmit = async () => {
|
|
|
+ const { valid } = await formPageRef.value.formRef.validate()
|
|
|
+ if (!valid) return
|
|
|
+ const obj = getValue()
|
|
|
+
|
|
|
+ // 更新标签时,至少需要提供一个要更新的项
|
|
|
+ if (type.value === 'edit') {
|
|
|
+ const isEqual = _.isEqual(obj, editItemData.value)
|
|
|
+ if (isEqual) return Snackbar.warning('请修改任意项后再提交!')
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ type.value === 'add' ? await createTalentTag(obj) : await updateTalentTag(editId.value, obj)
|
|
|
+ getList()
|
|
|
+ Snackbar.success(`${type.value === 'add' ? '新增' : '编辑'}成功`)
|
|
|
+ handleClose()
|
|
|
+ } catch {}
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|