Browse Source

自测版代码提交

master
ljlong_2630 9 months ago
parent
commit
63390cd8a2
  1. 4
      src/components/BasicForm/src/BasicForm.vue
  2. 183
      src/components/Detail/src/DetailDeviceLedger.vue
  3. 6
      src/utils/dict.ts
  4. 15
      src/utils/disposition/defaultButtons.ts
  5. 32
      src/utils/disposition/tabsList.ts
  6. 17
      src/views/eam/device/deviceAccounts/deviceAccounts.data.ts
  7. 5
      src/views/eam/device/deviceAccounts/index.vue
  8. 111
      src/views/eam/mold/moldAccounts/index.vue
  9. 71
      src/views/eam/mold/moldAccounts/moldAccounts.data.ts
  10. 117
      src/views/system/dept/DeptForm.vue
  11. 20
      src/views/system/dept/index.vue

4
src/components/BasicForm/src/BasicForm.vue

@ -115,6 +115,7 @@ import ButtonBase from '@/components/XButton/src/ButtonBase.vue'
import TableForm from '@/components/TableForm/src/TableForm.vue'
import TableFormCountPlan from '@/components/TableFormCountPlan/src/TableFormCountPlan.vue'
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import { log } from 'console'
const props = defineProps({
// TableForm /
@ -254,6 +255,9 @@ const formRef = ref() // 表单 Ref
const formSchema = ref(props.formAllSchemas?.formSchema)
const tableAllSchemas = ref(props.tableAllSchemas)
const tableFormRules = ref(props.tableFormRules)
console.log(88,props.formAllSchemas);
console.log(11);
// -
const buttondata = [

183
src/components/Detail/src/DetailDeviceLedger.vue

@ -88,7 +88,27 @@
:pagination="{ total: tableObjectRef.total }"
v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObjectRef.currentPage"
/>
>
<template #itemNumbers="{ row }">
<el-button type="primary" link @click="openDialog(row, '编号', row.number)">
<span>{{ row.itemNumbers }}</span>
</el-button>
</template>
</Table>
<!-- 单表切换tabs 展现table -->
<Table
v-if="isBasic && tabsExtend == 5"
:columns="detailAllSchemasRef.tableColumns"
:data="tableObjectRef.tableList"
:loading="tableObjectRef.loading"
:pagination="{ total: tableObjectRef.total }"
v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObjectRef.currentPage"
>
<template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonMilestoneClick($event, row)" />
</template>
</Table>
<Table
v-if="!isBasic && fromeWhere != 'countPlan'"
:columns="detailAllSchemasRef.tableColumns"
@ -150,7 +170,13 @@
:formTypeDetail="formTypeDetail"
:countPlanAllList="countPlanAllList"
/>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<Dialog
:title="dialogTitle"
v-model="dialogVisible"
:width="600"
:maxHeight="900"
:style="{height:'600px'}"
>
<Table
v-if="true"
:columns="dialogAllSchemasRef.tableColumns.filter(column => column.field !== 'action')"
@ -161,6 +187,28 @@
v-model:currentPage="dialogTableObjectRef.currentPage"
/>
</Dialog>
<Dialog
:title="dialogUploadTitle"
v-model="dialogUploadVisible"
:width="600"
:maxHeight="900"
:style="{height:'600px'}"
>
<el-form ref="fileDialogUploadRef" :model="fileDialogUploadData" :key="dialogFormKey">
<el-form-item label="文件上传">
<UploadFile v-model="fileDialogUploadData.filePathList" :limit="20" />
</el-form-item>
</el-form>
<el-button type="primary" @click="dialogUploadFile">点击修改</el-button>
</Dialog>
<!-- dialog表单弹窗添加/修改 -->
<BasicForm
ref="dialogFormRef"
@success="submitDialogForm"
:rules="dialogFormAllSchemasRules"
:formAllSchemas="dialogFormAllSchemas"
:isBusiness="false"
/>
</div>
</template>
@ -170,11 +218,6 @@ import * as defaultButtons from '@/utils/disposition/defaultButtons'
import BasicForm from '@/components/BasicForm/src/BasicForm.vue'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import DetailTable from '@/components/DetailTable/src/DetailTable.vue'
import { getCurrentInstance } from 'vue'
import { get } from 'http'
import { findIndex } from '@/utils'
const { proxy } = getCurrentInstance()
const changeFile = () => {}
defineOptions({ name: 'Detail' })
@ -191,6 +234,14 @@ const dialogTitle = ref()
const dialogAllSchemasRef = ref()
const dialogTableObjectRef = ref()
const dialogTableMethodsRef = ref()
const dialogUploadTitle = ref()
const fileDialogUploadData = ref({
filePathList: []
})
const dialogUploadVisible = ref(false)
const dialogUploadNumber = ref()
const dialogUploadBusiCode = ref()
const dialogFormKey = ref(0)
const props = defineProps({
//
@ -348,9 +399,40 @@ const props = defineProps({
// dialog
dialogAllSchemas: {
type: Object,
required: true,
required: false,
default: null
},
// dialog
dialogAllSchemasRules: {
type: Object,
required: false,
default: null
},
dialogFormAllSchemas: {
type: Object,
required: false,
default: null
},
dialogFormAllSchemasRules: {
type: Object,
required: false,
default: null
},
diaLogApiUpdate: {
type: Function,
required: false,
default: null
},
diaLogApiCreate: {
type: Function,
required: false,
default: null
},
milestoneFuncCode: {
type: String,
required: false,
default: null
}
})
const imageFormData = ref({
filePathList: []
@ -622,7 +704,8 @@ const emit = defineEmits([
'detailOpenForm',
'tableFormButton',
'openImage',
'subTabsChick'
'subTabsChick',
'milestoneOpenForm'
])
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
@ -758,6 +841,7 @@ const openDialog = async(row: any, titleName: any, titleValue: any) => {
getListApi: props.dialogApiPage, //
defaultParams: getDialogParams(row)
})
dialogVisible.value = true
dialogAllSchemasRef.value = props.dialogAllSchemas
dialogTableObjectRef.value = tableObject
dialogTableMethodsRef.value = tableMethods
@ -765,8 +849,87 @@ const openDialog = async(row: any, titleName: any, titleValue: any) => {
const { getList } = tableMethods
await getList()
updateKey.value += 1
getList() //
// getList() //
setBeiJian()
}
//
const setBeiJian = () => {
let isItemNUmbersTrue = false
isItemNUmbersTrue = dialogAllSchemasRef.value.tableColumns.some(
(item) => item.field == 'itemNumbers1'
)
if (!isItemNUmbersTrue) return
dialogTableObjectRef.value.tableList.forEach((item) => {
if (item.itemNumbers?.length > 0) {
let str = ''
item.itemNumbers.forEach((element) => {
str += element.name + ':' + element.qty + ','
})
item.itemNumbers1 = str.substring(0, str.length - 1)
}
})
}
// -
const butttondata = [
defaultButtons.mainListEditBtn(null), //
defaultButtons.uploadFileBtn(null),//
]
// -
const buttonMilestoneClick = async (val, row) => {
if (val == 'edit') {
//
openDialogForm('update', row)
} else if (val == 'upload') {
openDialogUpload(row)
}
}
function submitDialogForm(type, row) {
props.diaLogApiUpdate(row).then(res => {
console.log(res.code);
})
}
function openDialogUpload(row) {
dialogUploadVisible.value = true
getDialogUpload(row)
}
/** 添加/修改操作 */
const dialogFormRef = ref()
const openDialogForm = async (type: string, row?: number) => {
dialogFormRef.value.open(type, row)
}
const getDialogUpload = (row) => {
dialogUploadNumber.value = row.number
dialogUploadBusiCode.value = row.milestoneStage
props.getImageApi({
number: row.number,
funcCode: props.milestoneFuncCode
})
.then((res) => {
fileDialogUploadData.value.filePathList = res
dialogFormKey.value += 1
})
}
function dialogUploadFile() {
let data = {
number: dialogUploadNumber.value,
filePathList: fileDialogUploadData.value.filePathList.map((item) => item.url),
funcCode: props.milestoneFuncCode,
fileBusiType: dialogUploadBusiCode.value
}
props.uploadImage(data).then((res) => {
message.success('修改成功')
getImage()
})
}
</script>
<style lang="scss">
.el-drawer__body {

6
src/utils/dict.ts

@ -222,7 +222,8 @@ export enum DICT_TYPE {
REQEUST_MODE = 'reqeust_mode', // 申请模式
TIME_UNIT = 'time_unit', // 时间单位
COUNT_TYPE = 'count_type', // 盘点类型
DEVICE_DOC_TYPE = 'device_doc_type', // 盘点类型
DEVICE_DOC_TYPE = 'device_doc_type', // 设备文件类型
MOLD_DOC_TYPE = 'mold_doc_type', // 设备文件类型
COUNT_SCOPE_TYPE = 'count_scope_type', // 盘点范围类型
BARCODE_PREFIX = 'barcode_prefix', // 条码前缀
SETTLEMENT_TYPE = 'settlement_type', // 结算类型
@ -292,7 +293,8 @@ export enum DICT_TYPE {
ITEM_APPLY_STATUS = 'item_apply_status',//备件申领状态
JX_DETAILS_STATUS = 'jx_details_status', //检修明细状态
CLASSIFICATION = 'classification', //检修明细状态
DEPT_BUSI_TYPE = 'dept_busi_type', //部门类型
DEPT_GROUP = 'dept_group', //部门分组
}

15
src/utils/disposition/defaultButtons.ts

@ -918,6 +918,21 @@ export function finishOrderBtn(option:any) {
})
}
// 主列表-完成
export function uploadFileBtn(option:any) {
return __defaultBtnOption(option,{
label: '文件操作',
name: 'upload',
hide: false,
type: 'success',
color: '',
link: true, // 文本展现按钮
hasPermi: ''
})
}
// 默认按钮规则
function __defaultBtnOption(option:any,specific:any){
return {

32
src/utils/disposition/tabsList.ts

@ -26,3 +26,35 @@ export const DeviceLedgerTabsList = [
]
export const MoldLedgerTabsList = [
{
label: "设备图片",
prop: 'Image',
},
{
label: "关联文档",
prop: 'Word',
},
{
label: "关联备件",
prop: 'Part',
},
{
label: "报修记录",
prop: 'DeviceReportRecord',
},
{
label: "维修记录",
prop: 'RepairRecord',
},
{
label: "保养记录",
prop: 'MaintenanceRecord',
},
{
label: "里程碑",
prop: 'Milestone',
},
]

17
src/views/eam/device/deviceAccounts/deviceAccounts.data.ts

@ -1,5 +1,6 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import { selectAllFactoryArea } from '@/api/system/dept'
// 表单校验
export const DeviceAccountsRules = reactive({
@ -42,9 +43,21 @@ export const DeviceAccounts = useCrudSchemas(reactive<CrudSchema[]>([
}
},
{
label: '所属厂区编号',
label: '所属厂区',
field: 'factoryAreaNumber',
sort: 'custom'
sort: 'custom',
form: {
component: 'Select',
api: () => selectAllFactoryArea(),
componentProps: {
disabled: false,
optionsAlias: {
labelField: 'name',
valueField: 'id'
},
placeholder: "请选择所属厂区",
},
}
},
{
label: '采购时间',

5
src/views/eam/device/deviceAccounts/index.vue

@ -89,7 +89,6 @@ import download from '@/utils/download'
import {
DeviceAccounts,
DeviceAccountsRules,
UpImage
} from './deviceAccounts.data'
import { Item } from '@/views/eam/basic/item/item.data'
import * as ItemApi from '@/api/eam/basic/item'
@ -105,11 +104,13 @@ import { DeviceItem } from '@/views/eam/basic/deviceItem/deviceItem.data'
import * as deviceRepairApi from '@/api/eam/device/deviceRepair'
import * as uploadApi from '@/api/eam/upload'
import * as DeviceMaintainOrderMainApi from '@/api/eam/device/deviceMaintainOrderMain'
import * as DeviceMaintainOrderDetailApi from '@/api/eam/device/deviceMaintainOrderDetail'
import * as DeviceMaintenanceMainApi from '@/api/eam/device/deviceMaintenanceMain'
import * as deviceMaintenanceDetailApi from '@/api/eam/device/deviceMaintenanceDetail'
import {
DeviceMaintainOrderMain,
DeviceMaintainOrderDetail,
} from '../deviceMaintainOrderMain/deviceMaintainOrderMain.data'
import {
DeviceMaintenanceMain,
@ -355,6 +356,8 @@ const changeTabs = (item) => {
}
apiPage.value = DeviceMaintainOrderMainApi.getDeviceMaintainOrderMainPage
detailAllSchemas.value = DeviceMaintainOrderMain.allSchemas
dialogApiPage.value = DeviceMaintainOrderDetailApi.getDeviceMaintainOrderDetailPage
dialogAllSchemas.value = DeviceMaintainOrderDetail.allSchemas
}
// detailAllSchemas.value.tableColumns.map((item, index) => {
// if (item.field == 'action') {

111
src/views/eam/mold/moldAccounts/index.vue

@ -57,7 +57,7 @@
<SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" />
<!-- 详情 -->
<DetailMoldLedger
<DetailDeviceLedger
ref="detailRef"
:tabs="MoldLedgerTabsList"
:subTabs="MoldLedgerSubTabsList"
@ -70,6 +70,15 @@
:tableObjectExtend="tableObjectExtend"
:getImageApi="uploadApi.getImage"
:uploadImage="uploadApi.uploadImage"
:defaultParams="defaultParams"
:dialogApiPage="dialogApiPage"
:dialogAllSchemas="dialogAllSchemas"
:dialogAllSchemasRules="dialogAllSchemasRules"
:diaLogApiUpdate="MoldMilestoneApi.updateMoldMilestone"
:diaLogApiCreate="MoldMilestoneApi.createMoldMilestone"
:dialogFormAllSchemasRules="MoldMilestoneRules"
:dialogFormAllSchemas="MoldMilestone.allSchemas"
:milestoneFuncCode="milestone"
/>
<!-- 导入 -->
@ -86,20 +95,36 @@ import download from '@/utils/download'
import {
MoldAccounts,
MoldAccountsRules,
UpImage
MoldMilestone,
MoldMilestoneRules
} from './moldAccounts.data'
import { Item } from '@/views/eam/basic/item/item.data'
import * as ItemApi from '@/api/eam/basic/item'
// import { createMoldItemBatch, getMoldItemPage } from '@/api/eam/basic/rel'
import { createDeviceItemBatch, getDeviceItemPage } from '@/api/eam/basic/rel'
import * as MoldAccountsApi from '@/api/eam/mold/moldAccounts'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
// import { MoldLedgerTabsList } from '@/utils/disposition/tabsList'
import { MoldLedgerTabsList } from '@/utils/disposition/tabsList'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import DetailMoldLedger from '@/components/Detail/src/DetailDeviceLedger.vue'
import DetailDeviceLedger from '@/components/Detail/src/DetailDeviceLedger.vue'
import { MoldRepair } from '@/views/eam/mold/moldRepair/moldRepair.data'
import { DeviceItem } from '@/views/eam/basic/deviceItem/deviceItem.data'
import * as moldRepairApi from '@/api/eam/mold/moldRepair'
import * as uploadApi from '@/api/eam/upload'
import * as MoldMaintainOrderMainApi from '@/api/eam/mold/moldMaintainOrderMain'
// import * as MoldMaintainOrderDetailApi from '@/api/eam/mold/moldMaintainOrderDetail'
import * as MoldMaintenanceMainApi from '@/api/eam/mold/moldMaintenanceMain'
import * as moldMaintenanceDetailApi from '@/api/eam/mold/moldMaintenanceDetail'
import * as MoldMilestoneApi from '@/api/eam/basic/moldMilestone'
import {
MoldMaintainOrderMain,
MoldMaintainOrderDetail,
} from '../moldMaintainOrderMain/moldMaintainOrderMain.data'
import {
MoldMaintenanceMain,
MoldMaintenanceDetail
} from '../moldMaintenanceMain/moldMaintenanceMain.data'
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
defineOptions({ name: 'MoldAccounts' })
@ -109,7 +134,7 @@ const { t } = useI18n() // 国际化
const route = useRoute() //
const routeName = ref()
const moldNumber = ref()
const deviceNumber = ref()
routeName.value = route.name
const tableColumns = ref(MoldAccounts.allSchemas.tableColumns)
@ -118,6 +143,12 @@ const detailAllSchemas = ref()
const apiPage = ref()
const itemCodeRow = ref()
const tableObjectExtend = ref()
const defaultParams = ref({})
const dialogApiPage = ref()
const dialogAllSchemas = ref()
const dialogAllSchemasRules = ref()
const milestone = ref("milestone")
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
@ -292,7 +323,7 @@ const searchFormClick = (searchData) => {
getList() //
}
const MoldLedgerSubTabsList = getStrDictOptions(DICT_TYPE.DEVICE_DOC_TYPE)
const MoldLedgerSubTabsList = getStrDictOptions(DICT_TYPE.MOLD_DOC_TYPE)
const tabsExtend = ref()
const funcCode = ref('mold_mould_picture')
// tabs
@ -308,28 +339,48 @@ const changeTabs = (item) => {
// apiPage.value = PurchaseDetailApi.getPurchaseDetailPage
// detailAllSchemas.value = PurchaseMain.allSchemas
} else if (item.prop == 'Part') {
tabsExtend.value = 3
// apiPage.value = moldRepairApi.getMoldRepairPage
// detailAllSchemas.value = MoldRepair.allSchemas
tabsExtend.value = 4
defaultParams.value = {
deviceNumber: itemCodeRow
}
apiPage.value = getDeviceItemPage
detailAllSchemas.value = DeviceItem.allSchemas
} else if (item.prop == 'MoldReportRecord') {
tabsExtend.value = 3
tabsExtend.value = 4
defaultParams.value = {
deviceNumber: itemCodeRow
}
apiPage.value = moldRepairApi.getMoldRepairPage
detailAllSchemas.value = MoldRepair.allSchemas
} else if (item.prop == 'RepairRecord') {
tabsExtend.value = 3
// apiPage.value = ExpectinApi.getExpectinPage
// detailAllSchemas.value = Expectin.allSchemas
defaultParams.value = {
deviceNumber: itemCodeRow
}
apiPage.value = MoldMaintenanceMainApi.getMoldMaintenanceMainPage
detailAllSchemas.value = MoldMaintenanceMain.allSchemas
dialogApiPage.value = moldMaintenanceDetailApi.getMoldMaintenanceDetailPage
dialogAllSchemas.value = MoldMaintenanceDetail.allSchemas
} else if (item.prop == 'MaintenanceRecord') {
tabsExtend.value = 3
// apiPage.value = ExpectinApi.getExpectinPage
// detailAllSchemas.value = Expectin.allSchemas
defaultParams.value = {
deviceNumber: itemCodeRow
}
apiPage.value = MoldMaintainOrderMainApi.getMoldMaintainOrderMainPage
detailAllSchemas.value = MoldMaintainOrderMain.allSchemas
// dialogApiPage.value = MoldMaintainOrderDetailApi.getMoldMaintainOrderDetailPage
dialogAllSchemas.value = MoldMaintainOrderDetail.allSchemas
} else if (item.prop == 'Milestone') {
tabsExtend.value = 5
defaultParams.value = {
moldNumber: itemCodeRow
}
apiPage.value = MoldMilestoneApi.getMoldMilestonePage
detailAllSchemas.value = MoldMilestone.allSchemas
// dialogFormAllSchemasRules.value = MoldMilestoneRules
// dialogFormAllSchemas.value = MoldMilestone.allSchemas
}
// detailAllSchemas.value.tableColumns.map((item, index) => {
// if (item.field == 'action') {
// detailAllSchemas.value.tableColumns.splice(index, 1)
// }
// })
//
tableObjectExtend.value = [
{
key: 'itemCode',
@ -369,11 +420,11 @@ const openQrCode = async (number: String) => {
const searchTableRef = ref()
/** 绑定备件操作 */
const openItem = async (number: String) => {
moldNumber.value = number
deviceNumber.value = number
searchTableRef.value.open(
'选择备件',
Item.allSchemas,
getMoldItemList,
getDeviceItemList,
null,
Item.allSchemas.searchSchema,
true,
@ -385,14 +436,14 @@ const openItem = async (number: String) => {
}
const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => {
const moldItemRelList = selections.map((element) => ({
moldNumber: moldNumber.value,
const deviceItemRelList = selections.map((element) => ({
deviceNumber: deviceNumber.value,
itemNumber: element.number
}))
createMoldItemBatch(moldItemRelList).then((res) => {
createDeviceItemBatch(deviceItemRelList).then((res) => {
console.log('res', res)
})
console.log('moldItemRelList', moldItemRelList)
console.log('deviceItemRelList', deviceItemRelList)
}
const getItemWithOutBind = async () => {
@ -401,7 +452,7 @@ const getItemWithOutBind = async () => {
...Item.allSchemas.searchSchema
})
if (res.list?.length > 0) {
// const response = await getMoldItemPage(MoldAccounts.allSchemas.searchSchema);
// const response = await getDeviceItemPage(MoldAccounts.allSchemas.searchSchema);
// const filteredList = res.list.filter(item => {
// return !response.list?.some(element => {
// return item.number === element.itemNumber
@ -419,7 +470,7 @@ const getItemWithOutBind = async () => {
}
// getListApi getItemWithOutBind
const getMoldItemList = async () => {
const getDeviceItemList = async () => {
tableObject.loading = true
try {
const res = await getItemWithOutBind()
@ -434,4 +485,6 @@ const getMoldItemList = async () => {
tableObject.loading = false
}
}
</script>

71
src/views/eam/mold/moldAccounts/moldAccounts.data.ts

@ -157,6 +157,77 @@ export const UpImage = useCrudSchemas(reactive<CrudSchema[]>([
}
},
]))
export const MoldMilestoneRules = reactive({
number: [required],
moldNumber: [required],
})
export const MoldMilestone = useCrudSchemas(reactive<CrudSchema[]>([
{
label: 'id',
field: 'id',
sort: 'custom',
isSearch: true,
isForm: false
},
{
label: '编号唯一标识',
field: 'number',
sort: 'custom',
isSearch: true,
isForm: false
},
{
label: '模具编号',
field: 'moldNumber',
sort: 'custom',
isSearch: true,
isForm: false
},
{
label: '里程碑阶段',
field: 'milestoneStage',
sort: 'custom',
isSearch: true,
isForm: true
},
{
label: '里程碑日期',
field: 'milestoneDate',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
isForm: true,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
}
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))
// // 表单校验
// export const UpFileRules = reactive({
// filePath: [required],

117
src/views/system/dept/DeptForm.vue

@ -16,11 +16,35 @@
default-expand-all
placeholder="请选择上级部门"
value-key="deptId"
@change="handleNodeClick"
/>
</el-form-item>
<el-form-item label="部门名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入部门名称" />
</el-form-item>
<el-form-item label="部门分组" prop="group" v-if="groupDisabled">
<el-select v-model="formData.group" clearable placeholder="请选择部门类别">
<el-option
v-for="dict in getDeptGroupDict()"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="部门业务类别" prop="busiType" v-if="typeDisabled">
<el-select v-model="formData.busiType" clearable placeholder="请选择部门业务类别">
<el-option
v-for="dict in getDeptTypeDict()"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="层级" prop="level">
<el-input-number v-model="formData.level" disabled :min="0" controls-position="right" />
</el-form-item>
<el-form-item label="显示排序" prop="sort">
<el-input-number v-model="formData.sort" :min="0" controls-position="right" />
</el-form-item>
@ -51,9 +75,16 @@
</el-select>
</el-form-item>
<el-form-item label="班组类型" prop="classType"> <el-select v-model="formData.classType" clearable placeholder="请选择班组类型"> <el-option v-for="dict in getStrDictOptions(DICT_TYPE.CLASS_TYPE)" :key="dict.value"
<el-form-item label="班组类型" prop="classType" v-if="classTypeDisabled">
<el-select v-model="formData.classType" clearable placeholder="请选择班组类型">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.CLASS_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value" /> </el-select> </el-form-item>
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button type="primary" @click="submitForm"> </el-button>
@ -88,6 +119,9 @@ const formData = ref({
email: undefined,
status: CommonStatusEnum.ENABLE,
classType: undefined,
busiType: undefined,
level: undefined,
group: undefined
})
const formRules = reactive({
parentId: [{ required: true, message: '上级部门不能为空', trigger: 'blur' }],
@ -102,18 +136,14 @@ const formRules = reactive({
})
const formRef = ref() // Ref
const deptTree = ref() //
const deptList = ref<any[]>([]) //
const userList = ref<UserApi.UserVO[]>([]) //
const typeDisabled = ref(false)
const typeNum = ref(0)
const classTypeDisabled = ref(false)
const groupDisabled = ref(false)
console.log(getIntDictOptions(DICT_TYPE.DEVICE_MOLD_TYPE))
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
@ -133,6 +163,7 @@ const open = async (type: string, id?: number) => {
userList.value = await UserApi.getSimpleUserList()
//
await getTree()
initDept(id)
}
defineExpose({ open }) // open
@ -184,8 +215,72 @@ const resetForm = () => {
const getTree = async () => {
deptTree.value = []
const data = await DeptApi.getSimpleDeptList()
deptList.value = data
let dept: Tree = { id: 0, name: '顶级部门', children: [] }
dept.children = handleTree(data)
// disabled
const setDisabledBasedOnIsLeaf = (nodes) => {
nodes.forEach(node => {
//
if (node.level == 3) {
node.disabled = true;
}
//
if (node.children && node.children.length > 0) {
setDisabledBasedOnIsLeaf(node.children);
}
});
};
// dept.children
setDisabledBasedOnIsLeaf(dept.children);
deptTree.value.push(dept)
}
const handleNodeClick = async (value) => {
const selectedDept = findDept(deptList.value, value);
if (selectedDept.level == 1) {
typeDisabled.value = true
groupDisabled.value = true
} else {
typeDisabled.value = false
groupDisabled.value = false
}
if (selectedDept.level == 2) {
classTypeDisabled.value = true
} else {
classTypeDisabled.value = false
}
formData.value.level = selectedDept.level + 1;
}
const initDept = async (value) => {
const selectedDept = findDept(deptList.value, value);
if (selectedDept.level == 2) {
typeDisabled.value = true
groupDisabled.value = true
} else {
typeDisabled.value = false
groupDisabled.value = false
}
if (selectedDept.level == 3) {
classTypeDisabled.value = true
} else {
classTypeDisabled.value = false
}
}
const findDept = (list, value) => {
return list.find(item => item.id === value)
}
const getDeptTypeDict = () => {
return getStrDictOptions(DICT_TYPE.DEPT_BUSI_TYPE)
}
const getDeptGroupDict = () => {
return getStrDictOptions(DICT_TYPE.DEPT_GROUP)
}
</script>

20
src/views/system/dept/index.vue

@ -31,13 +31,29 @@
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" row-key="id" :default-expand-all="isExpandAll" v-if="refreshTable">
<el-table-column prop="name" label="部门名称" />
<el-table-column prop="name" label="部门名称" width="200" />
<el-table-column prop="leader" align="center" label="负责人">
<template #default="scope">
{{ userList.find((user) => user.id === scope.row.leaderUserId)?.nickname }}
</template>
</el-table-column>
<el-table-column prop="sort" align="center" label="排序" width="200" />
<el-table-column prop="level" align="center" label="层级" width="80" />
<el-table-column prop="group" align="center" label="部门分组" width="80">
<template #default="scope">
<dict-tag :type="DICT_TYPE.DEPT_GROUP" :value="scope.row.group"/>
</template>
</el-table-column>
<el-table-column prop="busiType" align="center" label="部门业务类别" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.DEPT_BUSI_TYPE" :value="scope.row.busiType"/>
</template>
</el-table-column>
<el-table-column prop="classType" align="center" label="所属班组" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CLASS_TYPE" :value="scope.row.classType"/>
</template>
</el-table-column>
<el-table-column prop="sort" align="center" label="排序" width="80" />
<el-table-column prop="status" align="center" label="状态" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />

Loading…
Cancel
Save