宁夏成套代码迁移

This commit is contained in:
BianLzhaoMin 2024-08-30 17:26:32 +08:00
parent d95efa5bd5
commit 42cc440727
2 changed files with 655 additions and 402 deletions

View File

@ -0,0 +1,28 @@
import request from '@/utils/request'
// 新增 成套设备
export const addCompleteSetToolsApi = (data) => {
return request.post('/material/maWhole/addOrUpdate', data)
}
// 查询 成套设备列表
export const getCompleteSetToolsApi = (data) => {
return request.get('/material/maWhole/selectList', {
params: data,
})
}
// 删除 成套设备单条数据
export const delCompleteSetToolsApi = (data) => {
return request.post('/material/maWhole/deleteById', data)
}
// 查询编辑 成套设备单
export const queryCompleteSetToolsApi = (data) => {
return request.get('/material/maWhole/selectListById', {
params: data,
})
}
// 查询 成套设备详情
export const queryCompleteSetDetailsApi = (data) => {
return request.get('/material/maWhole/selectListByWholeTypeName', {
params: data,
})
}

View File

@ -10,7 +10,17 @@
label-width="100px"
@submit.native.prevent
>
<el-form-item label="关键字" prop="keyWord">
<el-form-item label="成套设备名称" prop="wholeTypeName">
<el-input
v-model="formData.wholeTypeName"
placeholder="请输入成套设备名称"
clearable
maxlength="50"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="主体设备" prop="keyWord">
<el-input
v-model="formData.keyWord"
placeholder="请输入关键字"
@ -20,35 +30,104 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建日期" prop="keyWord">
<el-input
v-model="formData.keyWord"
placeholder="请输入关键字"
clearable
maxlength="50"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item> -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button
icon="el-icon-refresh"
size="mini"
@click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button
>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
/>
</el-row>
<!-- 列表 -->
<el-table :data="houseList">
<el-table-column label="序号" align="center" width="80" type="index" :index="indexContinuation(queryParams.pageNum, queryParams.pageSize)">
<!-- <template scope="scope">
<span>{{ (queryParams.pageNum - 1) * 10 + scope.$index + 1 }}</span>
</template> -->
<el-table :data="tableList" border>
<el-table-column
label="序号"
align="center"
width="80"
type="index"
:index="
indexContinuation(queryParams.pageNum, queryParams.pageSize)
"
>
</el-table-column>
<el-table-column prop="typeName" label="机具名称" min-width="280" align="center" />
<el-table-column prop="typeModelName" label="规格型号" min-width="280" align="center" />
<el-table-column prop="totalNum" label="套装所需配件数量" width="200" align="center" />
<el-table-column label="操作" align="center" width="310" fixed="right">
<el-table-column
prop="wholeTypeName"
label="成套设备名称"
align="center"
/>
<el-table-column
prop="typeModelName"
label="主体设备"
align="center"
/>
<el-table-column
prop="totalNum"
label="配套设备种类数量"
align="center"
/>
<el-table-column prop="nickName" label="创建人" align="center" />
<el-table-column
prop="createTime"
label="创建日期"
align="center"
/>
<el-table-column label="操作" align="center">
<template v-slot="{ row }">
<el-button size="mini" type="primary" icon="el-icon-search" @click="handleDetail(row)">查看明细</el-button>
<el-button type="primary" size="mini" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(row)">删除</el-button>
<!-- <el-button
type="text"
icon="el-icon-search"
@click="handleDetail(row)"
>查看</el-button
> -->
<el-button
type="text"
icon="el-icon-edit"
@click="handleEdit(row)"
>编辑</el-button
>
<el-button
type="text"
icon="el-icon-delete"
@click="handleDeleteRow(row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
@ -56,124 +135,132 @@
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:page.sync="formData.pageNum"
:limit.sync="formData.pageSize"
@pagination="getList"
/>
<!-- 弹框 -->
<el-dialog :title="title" :visible.sync="open" width="70%" :close-on-click-modal="false">
<!-- 表单 -->
<el-dialog
:title="title"
:visible.sync="open"
v-if="open"
width="80%"
:close-on-click-modal="false"
>
<el-form
:model="dialogForm"
ref="dialogForm"
label-width="100px"
:inline="true"
size="small"
@submit.native.prevent
ref="addFormRef"
:model="addCompleteForm"
:rules="addCompleteRules"
inline
label-width="120px"
>
<el-form-item
label="物品类型"
prop="parentId"
:rules="[{ required: true, message: '请选择物品类型', trigger: 'change' }]"
v-if="!isDetail"
>
<el-cascader
v-model="dialogForm.parentId"
placeholder="请选择物品类型"
:options="typeOptions"
filterable
clearable
@change="handleTypeOptions"
style="width: 330px"
v-if="!isDetail"
/>
</el-form-item>
<el-form-item
ref="typeTree"
label="选择配件"
prop="mountingsValue"
:rules="[{ required: true, message: '请选择配件', trigger: 'change' }]"
v-if="!isDetail"
>
<el-cascader
ref="mountingsTree"
v-model="dialogForm.mountingsValue"
placeholder="请选择配件"
:options="mountingsOptions"
:props="{ multiple: true }"
filterable
clearable
@change="handleMountingsOptions"
style="width: 330px"
/>
</el-form-item>
<el-form-item label=" " label-width="50px" v-if="!isDetail">
<el-button type="primary" size="mini" @click="addDialogList" icon="el-icon-plus">添加</el-button>
</el-form-item>
<!-- 详情 -->
<el-form-item label="关键字" prop="keyWord" v-if="isDetail">
<el-form-item label="成套名称" prop="completeSetName">
<el-input
v-model="dialogForm.keyWord"
placeholder="请输入关键字"
clearable
maxlength="50"
style="width: 240px"
@keyup.enter.native="handleSearch"
placeholder="请输入成套名称"
v-model="addCompleteForm.completeSetName"
/>
</el-form-item>
<el-form-item v-if="isDetail">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearch">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetSearch">重置</el-button>
<el-form-item
label="主体设备"
prop="mainDevice"
class="is-required"
>
<el-cascader
ref="mainDeviceRef"
placeholder="请选择主体设备"
:options="deviceTypeTreeNew"
:props="deviceTypeTreeProps"
v-model="addCompleteForm.mainDevice"
@change="selMainDevice"
:show-all-levels="false"
filterable
clearable
:disabled="mainDeviceDisabled"
/>
</el-form-item>
<el-form-item label="配套设备" prop="assortDevice">
<el-cascader
ref="assortDeviceRef"
placeholder="请选择配套设备"
:options="deviceTypeTreeNew"
:props="deviceTypeTreeProps"
v-model="addCompleteForm.assortDevice"
@change="selAssortDevice"
:show-all-levels="false"
filterable
clearable
/>
</el-form-item>
</el-form>
<el-table :data="dialogList">
<el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column prop="typeName" label="类型名称" align="center" />
<el-table-column prop="typeModelName" label="规格型号" align="center" />
<el-table-column prop="totalNum" label="每付所需数量" align="center">
<template v-slot="{ row }">
<el-input-number v-model="row.totalNum" size="mini" :min="1" v-if="!isDetail" />
<span v-else>{{ row.totalNum }}</span>
<el-row class="mb8">
<el-button type="primary" size="mini" @click="submitComplete"
> </el-button
>
</el-row>
<el-table :data="tempList" border max-height="400">
<el-table-column align="center" label="序号" type="index" />
<el-table-column
prop="typeName"
align="center"
label="设备名称"
/>
<el-table-column
prop="deviceType"
align="center"
label="设备型号"
/>
<el-table-column
prop="deviceAscription"
align="center"
label="设备所属"
/>
<el-table-column align="center" label="数量">
<template slot-scope="{ row }">
<el-input
v-model="row.deviceNum"
style="width: 180px"
placeholder="请输入数量"
@change="deviceNumChange"
maxlength="9"
/>
</template>
</el-table-column>
<el-table-column label="操作" width="100" align="center" v-if="!isDetail">
<template v-slot="{ row }">
<el-popconfirm
title="确认删除该数据?"
placement="top"
icon="el-icon-info"
@confirm="handleDeleteDialog(row)"
<!-- 操作列 -->
<el-table-column align="center" label="操作">
<template slot-scope="{ row }">
<el-button
size="mini"
type="danger"
@click="handleDelete(row)"
> </el-button
>
<el-button size="mini" type="danger" icon="el-icon-delete" slot="reference">删除</el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="open = false"> </el-button>
<el-button size="mini" type="primary" @click="dialogSubmit" :loading="isLoading" v-if="!isDetail">
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
// import {
// getDeviceTypeTree,
// addOrUpdateWhole,
// searchSelectList,
// searchSelectListById,
// deleteById,
// editRequest,
// } from '@/api/store/poleConfig'
import { getDeviceTypeTree } from '@/api/claimAndRefund/receive'
import {
getDeviceTypeTree,
addOrUpdateWhole,
searchSelectList,
searchSelectListById,
deleteById,
editRequest,
} from '@/api/store/poleConfig'
addCompleteSetToolsApi,
queryCompleteSetToolsApi,
getCompleteSetToolsApi,
delCompleteSetToolsApi,
} from '@/api/store/completeTools.js'
export default {
name: 'poleConfig',
data() {
@ -181,7 +268,9 @@ export default {
isLoading: false,
showSearch: true,
formData: {
keyWord: '',
wholeTypeName: '',
pageNum: 1,
pageSize: 10,
},
houseList: [],
title: '新增',
@ -204,17 +293,67 @@ export default {
keyWord: '',
},
rowId: '',
wholeTypeName: [],
pageContent: '成套设备新增',
addCompleteForm: {
completeSetName: '',
mainDevice: '',
assortDevice: '',
},
addCompleteRules: {
completeSetName: [
{
required: true,
trigger: 'blur',
message: '请输入成套名称',
},
{
max: 40,
message: '长度不能超过40个字符',
},
],
// mainDevice: [
// {
// required: true,
// },
// ],
// assortDevice: [
// {
// required: true,
// },
// ],
},
deviceTypeTreeProps: {
multiple: false,
value: 'id',
},
deviceTypeTreeNew: [], //
tempList: [],
mainDeviceDisabled: false,
saveParams: {
wholeTypeName: '', //
createBy: sessionStorage.getItem('userId'), //
parentId: '', // ID
// companyId: 101,
deviceInfo: [],
},
isEdit: false,
deviceName: '',
tableList: [],
}
},
created() {
this.getList()
getDeviceTypeTree().then(res => {
// typeOptions
const data = res.data
// this.typeOptions = this.getTree(data)
// this.mountingsOptions = this.getTree(data)
this.typeOptions = this.mountingsOptions = this.getTree(data)
})
//
this.getDeviceTypeTree()
// getDeviceTypeTree().then((res) => {
// // typeOptions
// const data = res.data
// // this.typeOptions = this.getTree(data)
// // this.mountingsOptions = this.getTree(data)
// this.typeOptions = this.mountingsOptions = this.getTree(data)
// })
// getDeviceTypeTree().then(res => {
// // mountingsOptions
// const data = res.data
@ -223,14 +362,19 @@ export default {
},
methods: {
//
async getList(data = {}) {
this.houseList = []
this.queryParams.pageNum = data.page || 1
this.queryParams.pageSize = data.limit || 10
this.queryParams.keyWord = this.formData.keyWord || ''
const res = await searchSelectList({ ...this.queryParams })
this.houseList = res.data.result
this.total = res.data.totalCount || 0
async getList() {
const res = await getCompleteSetToolsApi(this.formData)
console.log(res, '成套列表')
this.tableList = res.rows
this.total = res.total
// this.houseList = []
// this.queryParams.pageNum = data.page || 1
// this.queryParams.pageSize = data.limit || 10
// this.queryParams.keyWord = this.formData.keyWord || ''
// const res = await searchSelectList({ ...this.queryParams })
// this.houseList = res.data.result
// this.total = res.data.totalCount || 0
},
//
handleQuery() {
@ -254,170 +398,251 @@ export default {
//
handleAdd() {
//
this.title = '成套设备新增'
this.addCompleteForm = {
completeSetName: '',
mainDevice: '',
assortDevice: '',
}
this.tempList = []
this.open = true
this.title = '新增'
this.isDetail = false
this.isEdit = false
this.dialogForm.parentId = ''
this.dialogForm.mountingsValue = []
this.dialogList = []
setTimeout(() => {
this.$refs.dialogForm.resetFields()
}, 100)
},
//
handleDetail(row) {
this.rowId = row.id
this.open = true
this.isDetail = true
this.title = '详情'
this.dialogForm.keyWord = ''
this.getDetail({ id: row.id })
},
//
async getDetail({ id, keyWord = '' }) {
const res = await searchSelectListById({ id, keyWord })
this.dialogList = res.rows
},
//
handleEdit(row) {
this.rowId = row.id
this.open = true
this.isDetail = false
async handleEdit(row) {
this.title = '成套设备编辑'
this.addCompleteForm.completeSetName = row.wholeTypeName
this.addCompleteForm.mainDevice = row.deviceTypeId
this.saveParams.id = row.id
this.mainDeviceDisabled = true
this.isEdit = true
this.title = '编辑'
this.dialogList = []
this.$nextTick(() => {
this.$refs.dialogForm.resetFields()
})
console.log('🚀 ~ handleEdit ~ row.id:', row.id)
this.queryEdit(row.id)
const queryParams = {
id: row.id,
wholeTypeName: row.wholeTypeName,
pageNum: 1,
pageSize: 99999,
}
const { rows: res } = await queryCompleteSetToolsApi(queryParams)
this.tempList = res
this.open = true
},
async queryEdit(id) {
const { data } = await editRequest({ id })
this.dialogForm.parentId = data.typeList.fourId
this.dialogForm.mountingsValue = data.list.map(item => {
return [item.firstId, item.secondId, item.threeId, item.fourId]
})
this.dialogList = this.selectList = data.voList
},
//
handleDelete(row) {
//
this.$confirm('是否确认删除该数据?', '系统提示', {
//
handleDeleteRow(row) {
this.$confirm('是否确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
//
deleteById({ id: row.id }).then(() => {
delCompleteSetToolsApi({
id: row.id,
wholeTypeName: row.wholeTypeName,
})
.then((res) => {
this.$message({
type: 'success',
message: '删除成功!',
})
this.getList()
this.$message.success('删除成功')
})
.catch((err) => {
this.$message({
type: 'error',
message: '删除失败!',
})
})
.catch(() => {
this.$message.info('取消删除')
})
.catch(() => {})
},
//
handleTypeOptions(val) {
this.dialogForm.parentId = val[3]
},
//
handleMountingsOptions(val) {
console.log('🚀 ~ handleMountingsOptions ~ val:', val)
this.dialogList = []
this.dialogForm.mountingsValue = val
let selected = []
setTimeout(() => {
selected = this.$refs.mountingsTree.getCheckedNodes()
// level = 4 4
const filterSel = selected.filter(item => item.level === 4)
this.selectList = filterSel.map(item => {
return {
id: item.value,
typeName: item.pathLabels[2],
typeModelName: item.label,
totalNum: 1,
}
})
}, 100)
},
//
addDialogList() {
//
this.$refs.dialogForm.validate(valid => {
if (valid) {
this.dialogList = this.selectList
} else {
//
this.$message.warning('请填写完整信息')
return false
}
})
},
//
handleDeleteDialog(row) {
this.dialogList = this.dialogList.filter(item => item.id !== row.id)
},
getTree(data, level = 1) {
return data.map(item => {
if (item.children && item.children.length) {
return {
value: item.id,
label: item.label,
level,
children: this.getTree(item.children, level + 1),
}
} else {
return {
value: item.id,
label: item.label,
level,
disabled: level + 1 !== 5,
}
}
})
},
//
async dialogSubmit() {
//
this.$refs.dialogForm.validate(valid => {
if (valid) {
this.isLoading = true
if (!this.dialogList.length) {
this.isLoading = false
this.$message.warning('请点击添加按钮添加数据')
return false
/**
* 重庆宁夏共享成套 2024.8.30拷贝宁夏成套设备页面改造
* 以下为弹框内操作代码逻辑
*/
//
selMainDevice(val) {
this.$message.closeAll()
const checkNode = this.$refs['mainDeviceRef'].getCheckedNodes()
this.recursionGetDeviceName(
this.deviceTypeTreeNew,
val[val.length - 2],
)
if (checkNode.length < 1) return
const mainDeviceObj = {
deviceType: checkNode[0].label, //
deviceTypeId: val[val.length - 1], // Id
deviceNum: '', //
deviceAscription: '主体设备', //
ascriptionType: 1, // 1 2
typeName: this.deviceName,
}
const MaWholeSetDto = {
parentId: this.dialogForm.parentId,
wholeList: this.dialogList,
if (this.tempList.length === 0) {
this.tempList.unshift(mainDeviceObj)
} else {
//
const isRepeat = this.tempList.some(
(e) => e.deviceTypeId === mainDeviceObj.deviceTypeId,
)
if (isRepeat) {
this.$message.error(
'该设备已选择作为配套设备,不可作为主体设备!',
)
return
} else {
this.tempList.unshift(mainDeviceObj)
}
if (this.isEdit) {
MaWholeSetDto.id = this.rowId
}
addOrUpdateWhole(MaWholeSetDto)
.then(() => {
this.isLoading = false
this.mainDeviceDisabled = true
},
//
selAssortDevice(val) {
this.$message.closeAll()
const checkNode = this.$refs['assortDeviceRef'].getCheckedNodes()
this.recursionGetDeviceName(
this.deviceTypeTreeNew,
val[val.length - 2],
)
if (checkNode.length < 1) return
const assortDeviceObj = {
deviceType: checkNode[0].label, //
deviceTypeId: val[val.length - 1], // Id
deviceNum: '', //
deviceAscription: '配套设备', //
ascriptionType: 2, // 1 2
typeName: this.deviceName,
}
//
if (
this.tempList.length > 0 &&
this.tempList[0].deviceTypeId === assortDeviceObj.deviceTypeId
) {
this.$message.error(
'所选设备已作为主体设备,不可再作为配套设备!',
)
return
}
//
const isRepeat = this.tempList.some(
(e) => e.deviceTypeId === assortDeviceObj.deviceTypeId,
)
if (isRepeat) {
this.$message.error('该设备已添加,不可重复添加!')
return
} else {
this.tempList.push(assortDeviceObj)
}
},
//
handleDelete(row) {
this.tempList = this.tempList.filter(
(e) => e.deviceTypeId !== row.deviceTypeId,
)
//
if (row.ascriptionType === 1) {
this.mainDeviceDisabled = false
}
},
//
deviceNumChange(val) {
let reg = /^[1-9]\d*$/
if (!reg.test(val)) {
this.$message.error('请输入大于0的正整数')
}
},
//
submitComplete() {
this.$refs.addFormRef.validate(async (valid) => {
if (valid) {
let isNum = false
const isMainDevice = this.tempList.some(
(e) => e.ascriptionType === 1,
)
if (!isMainDevice) {
this.$message.error('请添加主体设备!')
return
}
// const isAssortDevice = this.tempList.some(
// (e) => e.ascriptionType === 2,
// )
// if (!isAssortDevice) {
// this.$message.error('')
// return
// }
try {
this.tempList.forEach((e) => {
if (!parseInt(e.deviceNum)) {
this.$message.error('请输入数量!')
isNum = true
throw new Error()
} else {
e.deviceNum = parseInt(e.deviceNum)
}
})
} catch (error) {}
if (isNum) return
this.saveParams.parentId = this.tempList[0].deviceTypeId
this.saveParams.wholeTypeName =
this.addCompleteForm.completeSetName
this.saveParams.deviceInfo = this.tempList
const res = await addCompleteSetToolsApi(this.saveParams)
if (res.code == 200) {
this.$message.success(
!this.title === '成套设备新增'
? '新增成功!'
: '修改成功!',
)
this.open = false
this.$message.success('保存成功')
this.tempList = []
this.getList()
})
.catch(() => {
this.isLoading = false
})
} else {
this.isLoading = false
this.$message.warning('请填写完整信息')
return false
}
}
})
},
//
async getDeviceTypeTree() {
const params = {
level: 4,
}
const res = await getDeviceTypeTree(params)
this.deviceTypeTreeNew = res.data
},
goBack() {
this.$emit('openHomePage')
this.tempList = []
},
//
recursionGetDeviceName(list, id) {
try {
list.map((e) => {
if (e.id == id) {
this.deviceName = e.label
throw new Error()
} else {
if (e.children && e.children.length > 0) {
this.recursionGetDeviceName(e.children, id)
}
}
})
} catch (error) {}
},
},
}
</script>