工具录入申请
This commit is contained in:
parent
ef8141e8df
commit
819bdd6c25
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = {
|
||||
printWidth: 120,
|
||||
tabWidth: 4,
|
||||
tabWidth: 2,
|
||||
semi: false,
|
||||
vueIndentScriptAndStyle: false,
|
||||
singleQuote: true,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export const getToolLedgerListApi = (data = {}) => {
|
|||
return request({
|
||||
url: '/material-mall/toolLedger/list',
|
||||
method: 'GET',
|
||||
params: data
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -14,6 +14,78 @@ export const getToolSelectApi = (data = {}) => {
|
|||
return request({
|
||||
url: '/material-mall/tool/getSelect',
|
||||
method: 'POST',
|
||||
data: data
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 工具录入申请-列表
|
||||
export const getToolApplyListApi = (data = {}) => {
|
||||
return request({
|
||||
url: '/material-mall/toolApply/list',
|
||||
method: 'GET',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 工具录入申请-删除
|
||||
export const deleteToolApplyApi = (data) => {
|
||||
return request({
|
||||
url: '/material-mall/toolApply/delete',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 新增工具-列表
|
||||
export const getListByApplyIdApi = (data) => {
|
||||
return request({
|
||||
url: '/material-mall/toolApply/listByApplyId',
|
||||
method: 'GET',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 新增工具-删除
|
||||
export const deleteToolApi = (data) => {
|
||||
return request({
|
||||
url: '/material-mall/toolApply/deleteDetail',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 类型树
|
||||
export const getTreeSelectApi = (data = {}) => {
|
||||
return request({
|
||||
url: '/material-mall/toolApply/getTreeSelect',
|
||||
method: 'GET',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 新增订单号
|
||||
export const addApplyCodeApi = (data = {}) => {
|
||||
return request({
|
||||
url: '/material-mall/toolApply/add',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 新增工具
|
||||
export const addToolApi = (data = {}) => {
|
||||
return request({
|
||||
url: '/material-mall/toolApply/addDetail',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 提交申请
|
||||
export const updateToolApplyApi = (data = {}) => {
|
||||
return request({
|
||||
url: '/material-mall/toolApply/update',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ aside {
|
|||
box-sizing: border-box;
|
||||
// display: flex;
|
||||
// flex-direction: column;
|
||||
//overflow-y: auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.components-container {
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@
|
|||
<el-input style="width: 100%" readonly v-model="form.label" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="Number(form.level) > 4 ? '规格型号' : '名称'" prop="typeName">
|
||||
<el-input style="width: 100%" v-model="form.typeName" placeholder="请输入规格型号" />
|
||||
<el-input style="width: 100%" v-model="form.typeName" placeholder="请输入规格型号" maxlength="99" />
|
||||
</el-form-item>
|
||||
<el-form-item label="管理模式" prop="manageType" v-if="Number(form.level) > 4">
|
||||
<el-select v-model="form.manageType" placeholder="请选择管理模式" clearable style="width: 100%">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,386 @@
|
|||
<template>
|
||||
<!-- 基础页面 -->
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<el-form
|
||||
v-show="showSearch"
|
||||
:model="queryParams"
|
||||
ref="queryForm"
|
||||
size="small"
|
||||
inline
|
||||
:rules="rules"
|
||||
@submit.native.prevent
|
||||
>
|
||||
<el-form-item label="关键字" prop="keyWord">
|
||||
<el-input
|
||||
v-model="queryParams.keyWord"
|
||||
placeholder="请输入关键字"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- 日期范围 -->
|
||||
<el-form-item label="查询日期" prop="timeRange">
|
||||
<el-date-picker
|
||||
v-model="queryParams.timeRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
clearable
|
||||
unlink-panels
|
||||
value-format="yyyy-MM-dd"
|
||||
format="yyyy-MM-dd"
|
||||
style="width: 240px"
|
||||
:picker-options="pickerOptions"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 表单按钮 -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
||||
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出数据</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
<el-table :data="tableList" highlight-current-row style="width: 100%" v-loading="isLoading" :max-height="650">
|
||||
<el-table-column
|
||||
type="index"
|
||||
width="55"
|
||||
label="序号"
|
||||
align="center"
|
||||
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column
|
||||
v-for="(column, index) in tableColumns"
|
||||
show-overflow-tooltip
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
align="center"
|
||||
>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-if="column.prop == 'outNum'">
|
||||
<span
|
||||
v-if="row.outNum > 0"
|
||||
style="color: #F56C6C; cursor: pointer; text-decoration: underline"
|
||||
@click="handleDialog(row, 'out')"
|
||||
>
|
||||
{{ row.outNum }}
|
||||
</span>
|
||||
<span v-else>{{ row.outNum }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 操作 -->
|
||||
<!-- <el-table-column label="操作" align="center" width="300">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button type="primary" size="mini" @click="">查看详情</el-button>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- 弹框 -->
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="70%">
|
||||
<el-form ref="dialogForm" :model="dialogForm" label-width="" size="small" inline @submit.native.prevent>
|
||||
<el-form-item label="关键字" prop="keyWord">
|
||||
<el-input v-model="dialogForm.keyWord" placeholder="请输入关键字" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleDialogQuery">查询</el-button>
|
||||
<el-button icon="el-icon-refresh" @click="handleDialogReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table
|
||||
:data="dialogList"
|
||||
fit
|
||||
highlight-current-row
|
||||
style="width: 100%"
|
||||
v-loading="isLoading"
|
||||
:max-height="500"
|
||||
>
|
||||
<el-table-column
|
||||
type="index"
|
||||
width="55"
|
||||
label="序号"
|
||||
align="center"
|
||||
:index="(index) => (dialogForm.pageNum - 1) * dialogForm.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column
|
||||
v-for="(column, index) in dialogColumns"
|
||||
:width="column.width"
|
||||
:show-overflow-tooltip="!column.unShowTooltip"
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
align="center"
|
||||
>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-if="column.prop == 'num'">
|
||||
<span v-if="isOut">{{ row.outNum }}</span>
|
||||
<span v-else>{{ row.inputNum }}</span>
|
||||
</template>
|
||||
<template v-slot="{ row }" v-else-if="column.prop == 'maCode'">
|
||||
<span>{{ row.maCode || '-' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="100">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button size="mini" plain icon="el-icon-zoom-in" @click="">查看</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
v-show="dlgTotal > 0"
|
||||
:total="dlgTotal"
|
||||
:page.sync="dialogForm.pageNum"
|
||||
:limit.sync="dialogForm.pageSize"
|
||||
@pagination="getDialogList"
|
||||
/>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import {} from '@/api'
|
||||
import { formatTime } from '@/utils/bonus.js'
|
||||
|
||||
export default {
|
||||
name: 'ToolsLedger',
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
showSearch: true,
|
||||
pickerOptions: {
|
||||
disabledDate(time) {
|
||||
return time.getTime() > Date.now()
|
||||
},
|
||||
},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
keyWord: '', // 关键字
|
||||
startTime: '', // 开始时间
|
||||
endTime: '', // 结束时间
|
||||
timeRange: [], // 创建日期范围
|
||||
},
|
||||
rules: [],
|
||||
total: 0, // 总条数
|
||||
// 表头
|
||||
tableColumns: [
|
||||
{ label: '物品种类', prop: 'constructionType' },
|
||||
{ label: '物品类型', prop: 'materialType' },
|
||||
{ label: '设备类型', prop: 'typeName' },
|
||||
{ label: '规格型号', prop: 'typeModelName' },
|
||||
{ label: '昨日库存', prop: 'preStoreNum' },
|
||||
{
|
||||
label: '出库数',
|
||||
prop: 'outNum',
|
||||
render: (h, { row }) => {
|
||||
return row.outNum > 0
|
||||
? h(
|
||||
'span',
|
||||
{
|
||||
style: { color: '#F56C6C', cursor: 'pointer', textDecoration: 'underline' },
|
||||
on: { click: () => this.handleDialog(row, 'out') },
|
||||
},
|
||||
row.outNum,
|
||||
)
|
||||
: h('span', {}, row.outNum)
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '入库数',
|
||||
prop: 'inputNum',
|
||||
render: (h, { row }) => {
|
||||
return row.inputNum > 0
|
||||
? h(
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409eff', cursor: 'pointer', textDecoration: 'underline' },
|
||||
on: { click: () => this.handleDialog(row, 'in') },
|
||||
},
|
||||
row.inputNum,
|
||||
)
|
||||
: h('span', {}, row.inputNum)
|
||||
},
|
||||
},
|
||||
{ label: '当前库存', prop: 'afterStoreNum' },
|
||||
],
|
||||
// 表格数据
|
||||
tableList: [],
|
||||
isOut: false, // 是否出库
|
||||
dialogTitle: '详情',
|
||||
dialogVisible: false,
|
||||
dialogForm: {
|
||||
keyWord: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
dlgTotal: 0, // 弹框总条数
|
||||
dialogColumns: [
|
||||
{ label: '设备类型', prop: 'typeName' },
|
||||
{ label: '规格型号', prop: 'typeModelName' },
|
||||
{ label: '设备编码', prop: 'maCode' },
|
||||
{ label: '数量', prop: 'num' },
|
||||
{ label: '操作人', prop: 'nickName' },
|
||||
{ label: '操作时间', prop: 'createTime' },
|
||||
{ label: '任务单号', prop: 'code' },
|
||||
],
|
||||
dialogList: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// // 往前一个月
|
||||
// let start = new Date()
|
||||
// start.setMonth(start.getMonth() - 1)
|
||||
const date = new Date()
|
||||
this.queryParams.timeRange = [this.format(date), this.format(date)]
|
||||
// this.getList()
|
||||
},
|
||||
methods: {
|
||||
format(date) {
|
||||
const y = date.getFullYear()
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${y}-${m}-${day}`
|
||||
},
|
||||
// 查询
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
// 重置
|
||||
handleReset() {
|
||||
this.$refs.queryForm.resetFields()
|
||||
const date = new Date()
|
||||
this.queryParams.timeRange = [this.format(date), this.format(date)]
|
||||
this.queryParams.pageNum = 1
|
||||
this.queryParams.pageSize = 10
|
||||
this.getList()
|
||||
},
|
||||
// 获取列表
|
||||
async getList() {
|
||||
console.log('列表-查询', this.queryParams)
|
||||
this.isLoading = true
|
||||
try {
|
||||
const params = {
|
||||
...this.queryParams,
|
||||
startTime: this.queryParams.timeRange ? this.queryParams.timeRange[0] : '',
|
||||
endTime: this.queryParams.timeRange ? this.queryParams.timeRange[1] : '',
|
||||
}
|
||||
delete params.timeRange
|
||||
console.log('🚀 ~ getList ~ params:', params)
|
||||
const res = await getInventoryLogListApi(params)
|
||||
console.log('🚀 ~ 获取列表 ~ res:', res)
|
||||
this.tableList = res.data.rows || []
|
||||
this.total = res.data.total || 0
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ 获取列表 ~ error:', error)
|
||||
this.tableList = []
|
||||
this.total = 0
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
handleDialog(row, type) {
|
||||
console.log('🚀 ~ handleDialog ~ row:', row)
|
||||
this.dialogTitle = type == 'out' ? '出库详情' : '入库详情'
|
||||
this.isOut = type == 'out' ? true : false
|
||||
this.dialogVisible = true
|
||||
this.dialogList = []
|
||||
setTimeout(() => {
|
||||
this.$refs.dialogForm.resetFields()
|
||||
this.dialogForm.typeId = row.typeId
|
||||
this.dialogForm.startTime = this.queryParams.timeRange ? this.queryParams.timeRange[0] : ''
|
||||
this.dialogForm.endTime = this.queryParams.timeRange ? this.queryParams.timeRange[1] : ''
|
||||
this.getDialogList()
|
||||
}, 100)
|
||||
},
|
||||
// 弹框查询
|
||||
handleDialogQuery() {
|
||||
this.dialogForm.pageNum = 1
|
||||
this.getDialogList()
|
||||
},
|
||||
// 重置
|
||||
handleDialogReset() {
|
||||
this.dialogForm.keyWord = ''
|
||||
this.dialogForm.pageNum = 1
|
||||
this.dialogForm.pageSize = 10
|
||||
this.getDialogList()
|
||||
},
|
||||
// 获取弹框列表
|
||||
async getDialogList() {
|
||||
try {
|
||||
this.isLoading = true
|
||||
const params = { ...this.dialogForm }
|
||||
console.log('🚀 ~ getDialogList ~ params:', params)
|
||||
const res = await getInventoryLogDetailsApi(params)
|
||||
console.log('🚀 ~ 获取弹框列表 ~ res:', res)
|
||||
this.dialogList = res.data.rows || []
|
||||
this.dlgTotal = res.data.total || 0
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ 获取弹框列表 ~ error:', error)
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
// 导出数据
|
||||
// formatTime(date) {
|
||||
// const year = date.getFullYear()
|
||||
// const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
// const day = String(date.getDate()).padStart(2, '0')
|
||||
// const hours = String(date.getHours()).padStart(2, '0')
|
||||
// const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
// const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||
// return `${year}${month}${day}_${hours}${minutes}${seconds}`
|
||||
// },
|
||||
// 导出数据
|
||||
handleExport() {
|
||||
// 提示
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '导出功能开发中,敬请期待!',
|
||||
})
|
||||
try {
|
||||
let fileName = `导出_${formatTime(new Date())}.xLsx`
|
||||
let url = '/material/backstage/costPush/exportPushCheck'
|
||||
const params = { ...this.queryParams }
|
||||
console.log('🚀 ~ 导出 ~ params:', params)
|
||||
// this.derive(url, params, fileName)
|
||||
// this.download(url, params, fileName)
|
||||
} catch (error) {
|
||||
console.log('导出数据失败', error)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
<template>
|
||||
<!-- 基础页面 -->
|
||||
<div class="app-container">
|
||||
<el-card v-show="showSearch" style="margin-bottom: 20px">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" inline @submit.native.prevent>
|
||||
<el-form-item label="工具名称" prop="parentTypeName">
|
||||
<el-input
|
||||
v-model="queryParams.parentTypeName"
|
||||
placeholder="请输入工具名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="规格型号" prop="typeName">
|
||||
<el-input
|
||||
v-model="queryParams.typeName"
|
||||
placeholder="请输入规格型号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="管理模式" prop="manageType">
|
||||
<el-select
|
||||
v-model="queryParams.manageType"
|
||||
placeholder="请选择管理模式"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 表单按钮 -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
||||
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card>
|
||||
<el-row :gutter="10" class="mb8" justify="end">
|
||||
<el-col :span="4">
|
||||
<span style="font-size: 20px; font-weight: 800">工具录入申请列表</span>
|
||||
</el-col>
|
||||
<el-col v-if="!routerParams.isView" :span="20" style="display: flex; justify-content: flex-end">
|
||||
<el-button type="primary" @click="handleNumDialog">新增数量工具</el-button>
|
||||
<el-button type="primary" @click="handleCodeDialog">新增编码工具</el-button>
|
||||
<el-button type="primary" @click="submit">提交申请</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="isLoading"
|
||||
:data="tableList"
|
||||
highlight-current-row
|
||||
border
|
||||
stripe
|
||||
:max-height="650"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column
|
||||
type="index"
|
||||
width="55"
|
||||
label="序号"
|
||||
align="center"
|
||||
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column
|
||||
v-for="(column, index) in tableColumns"
|
||||
show-overflow-tooltip
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
align="center"
|
||||
>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }">
|
||||
<component :is="column.render ? { render: (h) => column.render(h, { row }) } : 'span'">
|
||||
{{ !column.render ? row[column.prop] : '' }}
|
||||
</component>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" v-if="!routerParams.isView">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)" style="color: red"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- 数量 -->
|
||||
<AddNum ref="addNum" @getList="getList" />
|
||||
<!-- 编码 -->
|
||||
<AddCode ref="addCode" @getList="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getListByApplyIdApi, deleteToolApi, updateToolApplyApi } from '@/api/toolsManage'
|
||||
import AddNum from './components/AddNum'
|
||||
import AddCode from './components/AddCode'
|
||||
|
||||
export default {
|
||||
name: 'AddEditTools',
|
||||
components: { AddNum, AddCode },
|
||||
data() {
|
||||
return {
|
||||
routerParams: {},
|
||||
isLoading: false,
|
||||
showSearch: true,
|
||||
timeRange: [],
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
parentTypeName: null,
|
||||
typeName: null,
|
||||
manageType: null,
|
||||
applyId: null,
|
||||
},
|
||||
typeList: [
|
||||
{ label: '数量管理', value: '0' },
|
||||
{ label: '编码管理', value: '1' },
|
||||
],
|
||||
total: 0, // 总条数
|
||||
// 表头
|
||||
tableColumns: [
|
||||
{ label: '工具专业', prop: 'fourthParentName' },
|
||||
{ label: '施工类型', prop: 'greatGrandparentName' },
|
||||
{ label: '工具类型', prop: 'grandparentTypeName' },
|
||||
{ label: '工具名称', prop: 'parentTypeName' },
|
||||
{ label: '规格型号', prop: 'typeName' },
|
||||
{
|
||||
label: '管理模式',
|
||||
prop: 'manageType',
|
||||
render: (h, { row }) => {
|
||||
return row.manageType == '0' ? h('span', {}, '数量管理') : h('span', {}, '编码管理')
|
||||
},
|
||||
},
|
||||
{ label: '申请数量', prop: 'applyNum' },
|
||||
],
|
||||
// 表格数据
|
||||
tableList: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.routerParams = this.$route.query
|
||||
let title = '新增工具'
|
||||
if (this.routerParams.isView) {
|
||||
title = '查看工具'
|
||||
} else if (this.routerParams.isEdit) {
|
||||
title = '编辑工具'
|
||||
}
|
||||
this.queryParams.applyId = this.routerParams.applyId || ''
|
||||
const obj = Object.assign({}, this.$route, { title })
|
||||
this.$tab.updatePage(obj)
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
// 查询
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
// 重置
|
||||
handleReset() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.queryParams.pageSize = 10
|
||||
this.queryParams.parentId = '0'
|
||||
this.queryParams.level = '1'
|
||||
this.$refs.queryForm.resetFields()
|
||||
this.getList()
|
||||
},
|
||||
// 获取列表
|
||||
async getList(emit = {}) {
|
||||
console.log('🚀 ~ emit:', emit)
|
||||
if (emit.applyId) {
|
||||
this.queryParams.applyId = emit.applyId
|
||||
// 存到 route
|
||||
this.$route.query.applyId = this.queryParams.applyId
|
||||
}
|
||||
console.log('列表-查询', this.queryParams)
|
||||
this.isLoading = true
|
||||
try {
|
||||
const params = { ...this.queryParams }
|
||||
const res = await getListByApplyIdApi(params)
|
||||
this.tableList = res.rows || []
|
||||
this.total = res.total || 0
|
||||
} catch (error) {
|
||||
this.tableList = []
|
||||
this.total = 0
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
// 删除
|
||||
handleDelete(row) {
|
||||
console.log('🚀 ~ row:', row)
|
||||
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
this.isLoading = true
|
||||
try {
|
||||
await deleteToolApi({ typeId: row.typeId, applyId: this.queryParams.applyId })
|
||||
// 提示
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!',
|
||||
})
|
||||
this.getList()
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ error:', error)
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
handleNumDialog() {
|
||||
const applyId = this.queryParams.applyId
|
||||
this.$refs.addNum.openDialog(applyId)
|
||||
},
|
||||
handleCodeDialog() {
|
||||
const applyId = this.queryParams.applyId
|
||||
this.$refs.addCode.openDialog(applyId)
|
||||
},
|
||||
// 提交
|
||||
async submit() {
|
||||
this.$confirm('是否确定提交申请?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
this.isLoading = true
|
||||
try {
|
||||
await updateToolApplyApi({ id: this.queryParams.applyId, status: '1' })
|
||||
// 提示
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '操作成功!',
|
||||
})
|
||||
this.$tab.closeOpenPage({ path: '/toolsManage/applicantList' })
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ error:', error)
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
@ -0,0 +1,241 @@
|
|||
<template>
|
||||
<!-- 基础页面 -->
|
||||
<div class="app-container">
|
||||
<el-card v-show="showSearch" style="margin-bottom: 20px">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" inline @submit.native.prevent>
|
||||
<el-form-item label="申请人" prop="createBy">
|
||||
<el-input
|
||||
v-model="queryParams.createBy"
|
||||
placeholder="请输入申请人"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- 日期范围 -->
|
||||
<el-form-item label="申请日期">
|
||||
<el-date-picker
|
||||
v-model="timeRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
clearable
|
||||
unlink-panels
|
||||
value-format="yyyy-MM-dd"
|
||||
format="yyyy-MM-dd"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="审批状态" prop="status">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="请选择审批状态"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 表单按钮 -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
||||
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card>
|
||||
<el-row :gutter="10" class="mb8" justify="end">
|
||||
<el-col :span="24" style="display: flex; justify-content: flex-end">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增工具</el-button>
|
||||
</el-col>
|
||||
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" /> -->
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="isLoading"
|
||||
:data="tableList"
|
||||
highlight-current-row
|
||||
border
|
||||
stripe
|
||||
:max-height="650"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column
|
||||
type="index"
|
||||
width="55"
|
||||
label="序号"
|
||||
align="center"
|
||||
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column
|
||||
v-for="(column, index) in tableColumns"
|
||||
show-overflow-tooltip
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
align="center"
|
||||
>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-if="column.prop == 'status'">
|
||||
<el-tag v-if="row.status == '0'" type="info">草稿</el-tag>
|
||||
<el-tag v-if="row.status == '1'" type="warning">审核中</el-tag>
|
||||
<el-tag v-if="row.status == '2'" type="success">通过</el-tag>
|
||||
<el-tag v-if="row.status == '3'" type="danger">驳回</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button v-if="row.status != 0" size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button>
|
||||
<el-button v-if="row.status == 0" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button v-if="row.status == 0" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)" style="color: red"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getToolApplyListApi, deleteToolApplyApi } from '@/api/toolsManage'
|
||||
|
||||
export default {
|
||||
name: 'ApplicantList',
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
showSearch: true,
|
||||
timeRange: [],
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
status: null,
|
||||
createBy: null,
|
||||
startTime: null,
|
||||
endTime: null,
|
||||
},
|
||||
statusList: [
|
||||
{ label: '草稿', value: '0' },
|
||||
{ label: '审核中', value: '1' },
|
||||
{ label: '通过', value: '2' },
|
||||
{ label: '驳回', value: '3' },
|
||||
],
|
||||
total: 0, // 总条数
|
||||
// 表头
|
||||
tableColumns: [
|
||||
{ label: '录入单号', prop: 'code' },
|
||||
{ label: '申请录入数量', prop: 'total' },
|
||||
{ label: '申请人', prop: 'createBy' },
|
||||
{ label: '申请时间', prop: 'createTime' },
|
||||
{ label: '审批状态', prop: 'status' },
|
||||
{ label: '已通过数量', prop: 'passed' },
|
||||
{ label: '已驳回数量', prop: 'quantity' },
|
||||
],
|
||||
// 表格数据
|
||||
tableList: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
// 查询
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
// 重置
|
||||
handleReset() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.queryParams.pageSize = 10
|
||||
this.queryParams.parentId = '0'
|
||||
this.queryParams.level = '1'
|
||||
this.timeRange = []
|
||||
this.$refs.queryForm.resetFields()
|
||||
this.getList()
|
||||
},
|
||||
// 获取列表
|
||||
async getList() {
|
||||
console.log('列表-查询', this.queryParams)
|
||||
this.isLoading = true
|
||||
this.queryParams.startTime = this.timeRange && this.timeRange[0] ? this.timeRange[0] : null
|
||||
this.queryParams.endTime = this.timeRange && this.timeRange[1] ? this.timeRange[1] : null
|
||||
try {
|
||||
const params = { ...this.queryParams }
|
||||
const res = await getToolApplyListApi(params)
|
||||
this.tableList = res.rows || []
|
||||
this.total = res.total || 0
|
||||
} catch (error) {
|
||||
this.tableList = []
|
||||
this.total = 0
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
// 新增
|
||||
handleAdd() {
|
||||
this.$router.push({ path: '/toolsManage/addTools' })
|
||||
},
|
||||
// 查看
|
||||
handleView(row) {
|
||||
this.$router.push({ path: '/toolsManage/addTools', query: { applyId: row.id, isView: true } })
|
||||
},
|
||||
// 编辑
|
||||
handleEdit(row) {
|
||||
this.$router.push({ path: '/toolsManage/addTools', query: { applyId: row.id, isEdit: true } })
|
||||
},
|
||||
// 删除
|
||||
handleDelete(row) {
|
||||
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
this.isLoading = true
|
||||
try {
|
||||
await deleteToolApplyApi({ id: row.id })
|
||||
// 提示
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!',
|
||||
})
|
||||
this.getList()
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ error:', error)
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取弹框列表
|
||||
async getDialogList() {
|
||||
try {
|
||||
this.isLoading = true
|
||||
const params = { ...this.dialogForm }
|
||||
const res = await getInventoryLogDetailsApi(params)
|
||||
this.dialogList = res.data.rows || []
|
||||
this.dlgTotal = res.data.total || 0
|
||||
} catch (error) {
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
@ -0,0 +1,287 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="80%" :close-on-click-modal="false">
|
||||
<el-card style="margin-bottom: 20px">
|
||||
<el-form
|
||||
v-if="dialogVisible"
|
||||
ref="dialogForm"
|
||||
:model="dialogForm"
|
||||
:rules="rules"
|
||||
size="small"
|
||||
inline
|
||||
@submit.native.prevent
|
||||
>
|
||||
<el-form-item label="规格型号">
|
||||
<el-cascader
|
||||
v-model="typeIdList"
|
||||
:options="options"
|
||||
:props="{ value: 'typeId', label: 'typeName' }"
|
||||
clearable
|
||||
@change="handleChange"
|
||||
style="width: 400px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- 厂家 -->
|
||||
<el-form-item label="生产厂家">
|
||||
<el-select v-model="dialogForm.supplierId" placeholder="请选择厂家" clearable style="width: 240px">
|
||||
<el-option
|
||||
v-for="item in manufacturerSelect"
|
||||
:key="item.id"
|
||||
:label="item.label"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- 出厂日期 -->
|
||||
<el-form-item label="出厂日期">
|
||||
<el-date-picker
|
||||
v-model="dialogForm.productionDate"
|
||||
type="date"
|
||||
clearable
|
||||
placeholder="选择出厂日期"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- 申请数量 -->
|
||||
<el-form-item label="申请数量" prop="applyNum">
|
||||
<el-input-number
|
||||
v-model="dialogForm.applyNum"
|
||||
:min="1"
|
||||
:max="9999"
|
||||
:controls="false"
|
||||
placeholder="请输入申请数量"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item style="display: flex; justify-content: flex-end">
|
||||
<el-button type="primary" icon="el-icon-plus" :disabled="typeIdList.length == 0" @click="handleAdd"
|
||||
>点击填充</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-loading="isLoading">
|
||||
<el-row :gutter="10" class="mb8" justify="end">
|
||||
<el-col :span="24" style="display: flex; justify-content: flex-end">
|
||||
<el-button type="primary" :disabled="dialogList.length == 0" @click="submit">确定</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table :data="dialogList" border stripe highlight-current-row :max-height="500" style="width: 100%">
|
||||
<el-table-column type="index" width="55" label="序号" align="center" />
|
||||
<el-table-column
|
||||
v-for="(column, index) in dialogColumns"
|
||||
:width="column.width"
|
||||
:show-overflow-tooltip="!column.unShowTooltip"
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
align="center"
|
||||
>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-if="column.prop == 'supplierId'">
|
||||
<el-select v-model="row.supplierId" placeholder="请选择厂家" style="width: 150px">
|
||||
<el-option
|
||||
v-for="item in manufacturerSelect"
|
||||
:key="item.id"
|
||||
:label="item.label"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
<template v-slot="{ row }" v-else-if="column.prop == 'productionDate'">
|
||||
<el-date-picker
|
||||
v-model="row.productionDate"
|
||||
type="date"
|
||||
clearable
|
||||
placeholder="选择出厂日期"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width: 150px"
|
||||
/>
|
||||
</template>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-else-if="column.prop == 'toolPrice'">
|
||||
<el-input-number v-model="row.toolPrice" :min="0" :max="9999" :controls="false" style="width: 120px" />
|
||||
</template>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-else-if="column.prop == 'identifyCode'">
|
||||
<el-input v-model="row.identifyCode" maxlength="999" style="width: 120px" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="{ row, $index }">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete($index)" style="color: red"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getTreeSelectApi, addApplyCodeApi, addToolApi } from '@/api/toolsManage'
|
||||
import { getManufacturerSelectApi } from '@/api/EquipmentLedger'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
dialogTitle: '新增编码工具',
|
||||
dialogVisible: false,
|
||||
dialogForm: {
|
||||
applyId: null,
|
||||
typeId: null,
|
||||
supplierId: null,
|
||||
supplierName: null,
|
||||
productionDate: null,
|
||||
applyNum: 1,
|
||||
},
|
||||
rules: {
|
||||
applyNum: [{ required: true, message: '请输入申请数量', trigger: 'blur' }],
|
||||
},
|
||||
typeIdList: [],
|
||||
dialogColumns: [
|
||||
{ label: '工具专业', prop: 'fourthParentName' },
|
||||
{ label: '施工类型', prop: 'greatGrandparentName' },
|
||||
{ label: '工具类型', prop: 'grandparentTypeName' },
|
||||
{ label: '工具名称', prop: 'parentTypeName' },
|
||||
{ label: '规格型号', prop: 'typeName' },
|
||||
{ label: '计量单位', prop: 'unitName' },
|
||||
{ label: '生产厂家', prop: 'supplierId', width: 180 },
|
||||
{ label: '出厂日期', prop: 'productionDate', width: 180 },
|
||||
{ label: '资产原值', prop: 'toolPrice', width: 150 },
|
||||
{ label: '原始编码', prop: 'identifyCode', width: 150 },
|
||||
],
|
||||
dialogList: [],
|
||||
options: [],
|
||||
activeLabels: [],
|
||||
lastNode: null,
|
||||
manufacturerSelect: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openDialog(applyId) {
|
||||
this.dialogForm.applyId = applyId
|
||||
this.typeIdList = []
|
||||
this.dialogList = []
|
||||
this.dialogVisible = true
|
||||
this.getTreeSelect()
|
||||
this.getManufacturerSelect()
|
||||
},
|
||||
async getTreeSelect() {
|
||||
try {
|
||||
const res = await getTreeSelectApi({ manageType: 1 })
|
||||
this.options = res.data
|
||||
this.handleTree(this.options)
|
||||
} catch (error) {}
|
||||
},
|
||||
handleTree(tree) {
|
||||
for (const node of tree) {
|
||||
if (node.level === '5') {
|
||||
// 删除 children
|
||||
delete node.children
|
||||
} else if (node.children && node.children.length > 0) {
|
||||
// 继续递归下级
|
||||
this.handleTree(node.children)
|
||||
}
|
||||
}
|
||||
},
|
||||
handleChange(val) {
|
||||
this.dialogForm.typeId = val ? val[val.length - 1] : ''
|
||||
this.activeLabels = this.getLabelsFromValuePath(val, this.options)
|
||||
this.lastNode = this.findNodeById(this.options, val[val.length - 1])
|
||||
console.log('选中的 labels:', this.activeLabels)
|
||||
},
|
||||
getLabelsFromValuePath(valuePath, options) {
|
||||
let labels = []
|
||||
let currentLevel = options
|
||||
|
||||
for (const val of valuePath) {
|
||||
const node = currentLevel.find((item) => item.typeId === val)
|
||||
if (node) {
|
||||
labels.push(node.typeName)
|
||||
currentLevel = node.children || []
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return labels
|
||||
},
|
||||
findNodeById(tree, id) {
|
||||
for (const node of tree) {
|
||||
if (node.typeId === id) return node // 找到了就返回
|
||||
if (node.children) {
|
||||
const result = this.findNodeById(node.children, id)
|
||||
if (result) return result // 子节点中找到了
|
||||
}
|
||||
}
|
||||
return null // 没找到
|
||||
},
|
||||
handleAdd() {
|
||||
const typeId = this.typeIdList[this.typeIdList.length - 1]
|
||||
|
||||
for (let i = 0; i < this.dialogForm.applyNum; i++) {
|
||||
this.dialogList.unshift({
|
||||
applyId: this.dialogForm.applyId,
|
||||
typeId,
|
||||
fourthParentName: this.activeLabels[0],
|
||||
greatGrandparentName: this.activeLabels[1],
|
||||
grandparentTypeName: this.activeLabels[2],
|
||||
parentTypeName: this.activeLabels[3],
|
||||
typeName: this.activeLabels[4],
|
||||
unitName: this.lastNode.unitName,
|
||||
applyNum: 1,
|
||||
supplierId: this.dialogForm.supplierId,
|
||||
supplierName: this.dialogForm.supplierName,
|
||||
productionDate: this.dialogForm.productionDate,
|
||||
toolPrice: null,
|
||||
identifyCode: null,
|
||||
})
|
||||
}
|
||||
},
|
||||
handleDelete(index) {
|
||||
this.dialogList.splice(index, 1)
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!',
|
||||
})
|
||||
},
|
||||
// 获取厂家
|
||||
async getManufacturerSelect() {
|
||||
try {
|
||||
const res = await getManufacturerSelectApi()
|
||||
this.manufacturerSelect = res.data
|
||||
} catch (error) {}
|
||||
},
|
||||
// 提交
|
||||
async submit() {
|
||||
try {
|
||||
this.isLoading = true
|
||||
if (!this.dialogForm.applyId) {
|
||||
const res = await addApplyCodeApi()
|
||||
this.dialogForm.applyId = res.data.id
|
||||
this.dialogList.forEach((item) => {
|
||||
item.applyId = res.data.id
|
||||
})
|
||||
}
|
||||
await addToolApi(this.dialogList)
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '操作成功!',
|
||||
})
|
||||
this.dialogVisible = false
|
||||
this.$emit('getList', { applyId: this.dialogForm.applyId })
|
||||
} catch (error) {
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="70%" :close-on-click-modal="false">
|
||||
<el-card style="margin-bottom: 20px">
|
||||
<el-form v-if="dialogVisible" ref="dialogForm" :model="dialogForm" size="small" inline @submit.native.prevent>
|
||||
<el-form-item label="规格型号">
|
||||
<el-cascader
|
||||
v-model="typeIdList"
|
||||
:options="options"
|
||||
:props="{ value: 'typeId', label: 'typeName' }"
|
||||
clearable
|
||||
@change="handleChange"
|
||||
style="width: 400px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-plus" :disabled="typeIdList.length == 0" @click="handleAdd"
|
||||
>点击填充</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-loading="isLoading">
|
||||
<el-row :gutter="10" class="mb8" justify="end">
|
||||
<el-col :span="24" style="display: flex; justify-content: flex-end">
|
||||
<el-button type="primary" :disabled="dialogList.length == 0" @click="submit">确定</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table :data="dialogList" border stripe highlight-current-row :max-height="500" style="width: 100%">
|
||||
<el-table-column type="index" width="55" label="序号" align="center" />
|
||||
<el-table-column
|
||||
v-for="(column, index) in dialogColumns"
|
||||
:width="column.width"
|
||||
:show-overflow-tooltip="!column.unShowTooltip"
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
align="center"
|
||||
>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-if="column.prop == 'applyNum'">
|
||||
<el-input-number
|
||||
v-model="row.applyNum"
|
||||
:min="1"
|
||||
:max="9999"
|
||||
:precision="0"
|
||||
:controls="false"
|
||||
style="width: 120px"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="{ row, $index }">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(index)" style="color: red"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getTreeSelectApi, addApplyCodeApi, addToolApi } from '@/api/toolsManage'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
dialogTitle: '新增数量工具',
|
||||
dialogVisible: false,
|
||||
dialogForm: {
|
||||
applyId: null,
|
||||
typeId: null,
|
||||
},
|
||||
typeIdList: [],
|
||||
dialogColumns: [
|
||||
{ label: '工具专业', prop: 'fourthParentName' },
|
||||
{ label: '施工类型', prop: 'greatGrandparentName' },
|
||||
{ label: '工具类型', prop: 'grandparentTypeName' },
|
||||
{ label: '工具名称', prop: 'parentTypeName' },
|
||||
{ label: '规格型号', prop: 'typeName' },
|
||||
{ label: '计量单位', prop: 'unitName' },
|
||||
{ label: '申请数量', prop: 'applyNum', width: 150 },
|
||||
],
|
||||
dialogList: [],
|
||||
options: [],
|
||||
activeLabels: [],
|
||||
lastNode: null,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openDialog(applyId) {
|
||||
console.log('🚀 ~ applyId:', applyId)
|
||||
this.dialogForm.applyId = applyId
|
||||
this.typeIdList = []
|
||||
this.dialogList = []
|
||||
this.dialogVisible = true
|
||||
this.getTreeSelect()
|
||||
},
|
||||
async getTreeSelect() {
|
||||
try {
|
||||
const res = await getTreeSelectApi({ manageType: 0 })
|
||||
console.log('🚀 ~ res:', res)
|
||||
this.options = res.data
|
||||
this.handleTree(this.options)
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ error:', error)
|
||||
}
|
||||
},
|
||||
handleTree(tree) {
|
||||
for (const node of tree) {
|
||||
if (node.level === '5') {
|
||||
// 删除 children
|
||||
delete node.children
|
||||
} else if (node.children && node.children.length > 0) {
|
||||
// 继续递归下级
|
||||
this.handleTree(node.children)
|
||||
}
|
||||
}
|
||||
},
|
||||
handleChange(val) {
|
||||
console.log('🚀 ~ val:', val)
|
||||
this.dialogForm.typeId = val ? val[val.length - 1] : ''
|
||||
this.activeLabels = this.getLabelsFromValuePath(val, this.options)
|
||||
this.lastNode = this.findNodeById(this.options, val[val.length - 1])
|
||||
console.log('🚀 ~ this.lastNode:', this.lastNode)
|
||||
console.log('选中的 labels:', this.activeLabels)
|
||||
},
|
||||
getLabelsFromValuePath(valuePath, options) {
|
||||
let labels = []
|
||||
let currentLevel = options
|
||||
|
||||
for (const val of valuePath) {
|
||||
const node = currentLevel.find((item) => item.typeId === val)
|
||||
if (node) {
|
||||
labels.push(node.typeName)
|
||||
currentLevel = node.children || []
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return labels
|
||||
},
|
||||
findNodeById(tree, id) {
|
||||
for (const node of tree) {
|
||||
if (node.typeId === id) return node // 找到了就返回
|
||||
if (node.children) {
|
||||
const result = this.findNodeById(node.children, id)
|
||||
if (result) return result // 子节点中找到了
|
||||
}
|
||||
}
|
||||
return null // 没找到
|
||||
},
|
||||
handleAdd() {
|
||||
console.log('🚀 ~ handleAdd:', this.dialogForm.typeId)
|
||||
const typeId = this.typeIdList[this.typeIdList.length - 1]
|
||||
if (this.dialogList.some((item) => item.typeId === typeId)) {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '该工具已添加!',
|
||||
})
|
||||
return
|
||||
}
|
||||
this.dialogList.unshift({
|
||||
applyId: this.dialogForm.applyId,
|
||||
typeId,
|
||||
fourthParentName: this.activeLabels[0],
|
||||
greatGrandparentName: this.activeLabels[1],
|
||||
grandparentTypeName: this.activeLabels[2],
|
||||
parentTypeName: this.activeLabels[3],
|
||||
typeName: this.activeLabels[4],
|
||||
unitName: this.lastNode.unitName,
|
||||
applyNum: 1,
|
||||
})
|
||||
console.log('🚀 ~ this.dialogList:', this.dialogList)
|
||||
},
|
||||
handleDelete(index) {
|
||||
this.dialogList.splice(index, 1)
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!',
|
||||
})
|
||||
},
|
||||
async submit() {
|
||||
try {
|
||||
this.isLoading = true
|
||||
if (!this.dialogForm.applyId) {
|
||||
const res = await addApplyCodeApi()
|
||||
console.log('🚀 ~ res:', res)
|
||||
this.dialogForm.applyId = res.data.id
|
||||
this.dialogList.forEach((item) => {
|
||||
item.applyId = res.data.id
|
||||
})
|
||||
}
|
||||
await addToolApi(this.dialogList)
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '操作成功!',
|
||||
})
|
||||
this.dialogVisible = false
|
||||
this.$emit('getList', { applyId: this.dialogForm.applyId })
|
||||
} catch (error) {
|
||||
console.log('🚀 ~ error:', error)
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
Loading…
Reference in New Issue