generated from Leo_Ding/web-template
即将产品-混乱中
This commit is contained in:
parent
c561186c46
commit
56152eb632
5
.env.dev
5
.env.dev
@ -12,7 +12,8 @@ VITE_ROUTER_BASE=/
|
||||
VITE_ROUTER_HISTORY=hash
|
||||
|
||||
# api
|
||||
VITE_API_BASIC=https://api.hailin-keji.com
|
||||
#VITE_API_BASIC=https://api.hailin-keji.com
|
||||
VITE_API_BASIC=http://10.10.1.6:8060
|
||||
VITE_API_HTTP=/api/v1/
|
||||
# storage
|
||||
VITE_STORAGE_NAMESPACE = gin-admin_local_
|
||||
VITE_STORAGE_NAMESPACE = gin-admin_local_
|
||||
|
||||
@ -11,7 +11,8 @@ VITE_PERMISSION=false
|
||||
VITE_ROUTER_HISTORY=hash
|
||||
|
||||
# api
|
||||
VITE_API_BASIC=https://mock.apifox.cn/m1/3156808-0-default
|
||||
#VITE_API_BASIC=https://mock.apifox.cn/m1/3156808-0-default
|
||||
VITE_API_BASIC=http://10.10.1.6:8060
|
||||
|
||||
# storage
|
||||
VITE_STORAGE_NAMESPACE=admin_test_
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
import request from '@/utils/request'
|
||||
// 获取产品列表
|
||||
export const getProductsList = (params) => request.basic.get('/api/v1/products', params)
|
||||
|
||||
// 获取产品单条数据
|
||||
export const getProductsItem = (id) => request.basic.get(`/api/v1/products/${id}`)
|
||||
// 添加产品
|
||||
@ -14,10 +13,10 @@ export const updateProductsItem = (id, params) => request.basic.put(`/api/v1/pro
|
||||
// 删除产品
|
||||
export const delProductsItem = (id) => request.basic.delete(`/api/v1/products/${id}`)
|
||||
// 获取产品类别列表
|
||||
export const getProduct = (params) => request.basic.get('/api/v1/products/job_areas', params)
|
||||
export const getProductCategory = (params) => request.basic.get('/api/v1/products/categorys', params)
|
||||
// 获取产品适用对象
|
||||
export const getProductObj = (params) => request.basic.get('/api/v1/products/job_areas', params)
|
||||
export const getProductObj = (params) => request.basic.get('/api/v1/products/target', params)
|
||||
// 添加产品类别
|
||||
export const createProduct = (params) => request.basic.post('/api/v1/products/job_areas', params)
|
||||
export const createProductCategory = (params) => request.basic.post('/api/v1/products/categorys', params)
|
||||
// 添加适用对象产品
|
||||
export const createProductObj = (params) => request.basic.post('/api/v1/products/job_areas', params)
|
||||
export const createProductObj = (params) => request.basic.post('/api/v1/products/target', params)
|
||||
|
||||
@ -27,8 +27,16 @@
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'适用对象'" name="target">
|
||||
<a-textarea :placeholder="'请输入岗位职责'" v-model:value="formData.target"></a-textarea>
|
||||
<div style="display: flex;justify-content: space-between;">
|
||||
<a-select v-model:value="formData.target" allowClear>
|
||||
<a-select-option v-for="item in areaList" :value="item.code">{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
<a-button type="primary" @click="childOpen = true">新增适用对象</a-button>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item :label="'适用对象'" name="target">-->
|
||||
<!-- <a-textarea :placeholder="'请输入岗位职责'" v-model:value="formData.target"></a-textarea>-->
|
||||
<!-- </a-form-item>-->
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'功能特点'" name="feature">
|
||||
@ -104,7 +112,7 @@
|
||||
</a-card>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
<a-modal ref="modalRef" v-model:open="childOpen" :wrap-style="{ overflow: 'hidden' }" @ok="childHandleOk">
|
||||
<a-modal ref="modalRef" v-model:open="childOpen" :wrap-style="{ overflow: 'hidden' }" @ok="handleCombinedOk">
|
||||
<a-card class="mb-8-2">
|
||||
<a-form ref="areaFormRef" :model="formArea" :rules="areaFormRules">
|
||||
<a-row :gutter="12">
|
||||
@ -141,6 +149,13 @@ import { useForm, useModal,useSpining } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import dayjs from 'dayjs'
|
||||
import {
|
||||
createProductCategory,
|
||||
createProductObj, createProductsItem,
|
||||
getProductCategory,
|
||||
getProductObj,
|
||||
getProductsItem, updateProductsItem,
|
||||
} from '@/apis/modules/products'
|
||||
const areaFormRef = ref()
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
@ -167,26 +182,48 @@ formRules.value = {
|
||||
}
|
||||
const areaFormRules = {
|
||||
categoryIDName: [{ required: true, message: '请输入产品类别' }],
|
||||
composeName: [{ required: true, message: '请输入产品适用对象' }],
|
||||
targetName: [{ required: true, message: '请输入产品适用对象' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
}
|
||||
const initData = async () => {
|
||||
const initDataBatch = async (configs) => {
|
||||
try {
|
||||
showSpining()
|
||||
const { success, data, total } = await apis.products.getAreasList({ pageSize: 999, page: 1, })
|
||||
if (config('http.code.success') === success) {
|
||||
hideSpining()
|
||||
areaList.value = data.map(item => {
|
||||
if (item.status === 'enabled') {
|
||||
return { code: item.id, name: item.name }
|
||||
}
|
||||
})
|
||||
}
|
||||
const responses = await Promise.all(
|
||||
configs.map(({ apiFunc }) => apiFunc({ pageSize: 999, page: 1 }))
|
||||
)
|
||||
|
||||
configs.forEach(({ nameKey, resultKey }, index) => {
|
||||
const { success, data } = responses[index]
|
||||
if (config('http.code.success') === success) {
|
||||
areaList.value = [
|
||||
...areaList.value,
|
||||
...data
|
||||
.filter(item => item.status === 'enabled')
|
||||
.map(item => ({
|
||||
code: item.id,
|
||||
[resultKey]: item[nameKey],
|
||||
}))
|
||||
]
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
message.error({ content: error.message })
|
||||
} finally {
|
||||
hideSpining()
|
||||
}
|
||||
}
|
||||
initDataBatch([
|
||||
{
|
||||
apiFunc: apis.products.getProductCategory,
|
||||
nameKey: 'name',
|
||||
resultKey: 'categoryIDName'
|
||||
},
|
||||
{
|
||||
apiFunc: apis.products.getProductObj,
|
||||
nameKey: 'name',
|
||||
resultKey: 'targetName'
|
||||
}
|
||||
])
|
||||
|
||||
/**
|
||||
* 新建
|
||||
@ -194,29 +231,46 @@ const initData = async () => {
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '薪资招聘岗位',
|
||||
title: '产品中心',
|
||||
})
|
||||
initData()
|
||||
formData.value.status = 'enabled'
|
||||
}
|
||||
|
||||
//新建基地
|
||||
|
||||
//新建产品类别
|
||||
const childHandleOk = async () => {
|
||||
areaFormRef.value.validateFields().then(async (values) => {
|
||||
try {
|
||||
const params = { ...formArea.value }
|
||||
const { success } = await apis.recruitment.createAreaItem(params)
|
||||
const { success } = await apis.products.createProductCategory(params)
|
||||
if (success) message.success('新增成功')
|
||||
childOpen.value = false
|
||||
formArea.value = { name: '', status: 'enabled' }
|
||||
formArea.value = { categoryIDName: '', status: 'enabled' }
|
||||
initData()
|
||||
} catch (error) {
|
||||
message.error(error.message)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
//新建产品适用对象
|
||||
const childHandleObjOk = async () => {
|
||||
areaFormRef.value.validateFields().then(async (values) => {
|
||||
try {
|
||||
const params = { ...formArea.value }
|
||||
const { success } = await apis.products.createProductObj(params)
|
||||
if (success) message.success('新增成功')
|
||||
childOpen.value = false
|
||||
formArea.value = { targetName: '', status: 'enabled' }
|
||||
initData()
|
||||
} catch (error) {
|
||||
message.error(error.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
const handleCombinedOk = () => {
|
||||
childHandleOk();
|
||||
childHandleObjOk();
|
||||
};
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
@ -225,7 +279,7 @@ async function handleEdit(record = {}) {
|
||||
type: 'edit',
|
||||
title: t('pages.system.user.edit'),
|
||||
})
|
||||
const { data, success } = await apis.recruitment.getItem(record.id).catch()
|
||||
const { data, success } = await apis.products.getProductsItem(record.id).catch()
|
||||
if (!success) {
|
||||
hideModal()
|
||||
return
|
||||
@ -250,12 +304,12 @@ function handleOk() {
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.recruitment.createItem(params).catch((error) => {
|
||||
result = await apis.products.createProductsItem(params).catch((error) => {
|
||||
throw new Error(error)
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.recruitment.updateItem(formData.value.id, params).catch(() => {
|
||||
result = await apis.products.updateProductsItem(formData.value.id, params).catch(() => {
|
||||
throw new Error(error)
|
||||
})
|
||||
break
|
||||
|
||||
@ -107,18 +107,6 @@ defineOptions({
|
||||
name: 'components',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
// const columns = [
|
||||
// { title: '产品名称', dataIndex: 'title', width: 120, },
|
||||
// { title: '产品类别', dataIndex: 'categoryID', key: 'categoryID', width: 120 },
|
||||
// { title: '原料组成', dataIndex: 'compose', key: 'compose',width: 120},
|
||||
// { title: '适用对象', dataIndex: 'target',width: 120},
|
||||
// { title: '功能特点', dataIndex: 'feature', width: 120, align: 'center'},
|
||||
// { title: '产品标准', dataIndex: 'standard', width: 120, align: 'center'},
|
||||
// { title: '产品图片', dataIndex: 'images', width: 120, align: 'center'},
|
||||
// { title: '产品排序', dataIndex: 'sequence', width: 120, align: 'center'},
|
||||
// { title: '产品状态', dataIndex: 'status',width:120 , align: 'center'},
|
||||
// { title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||
// ]
|
||||
const columns = [
|
||||
{ title: '产品名称', dataIndex: 'title', width: 120 },
|
||||
{ title: '产品类别', dataIndex: 'categoryID', key: 'categoryID', width: 120 },
|
||||
@ -254,16 +242,6 @@ async function onOk() {
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getPageList()
|
||||
}
|
||||
|
||||
function addImage() {
|
||||
images.value.push('')
|
||||
}
|
||||
|
||||
function removeImage(index) {
|
||||
if (images.value.length > 1) {
|
||||
images.value.splice(index, 1)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user