代码回滚
This commit is contained in:
parent
4b594ea37d
commit
e72ab32224
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,556 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 首页搜索 -->
|
||||
<el-form
|
||||
:model="formData"
|
||||
ref="formData"
|
||||
size="small"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="100px"
|
||||
@submit.native.prevent
|
||||
>
|
||||
<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="请输入关键字"
|
||||
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="请输入关键字"
|
||||
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-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-col>
|
||||
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
<!-- 列表 -->
|
||||
<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="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
|
||||
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>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="formData.pageNum"
|
||||
:limit.sync="formData.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 弹框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" v-if="open" width="80%" :close-on-click-modal="false">
|
||||
<el-form ref="addFormRef" :model="addCompleteForm" :rules="addCompleteRules" inline label-width="120px">
|
||||
<el-form-item label="成套名称" prop="completeSetName">
|
||||
<el-input placeholder="请输入成套名称" v-model="addCompleteForm.completeSetName" />
|
||||
</el-form-item>
|
||||
<el-form-item label="抱杆设备" prop="mainDevice" class="is-required">
|
||||
<el-cascader
|
||||
clearable
|
||||
filterable
|
||||
ref="mainDeviceRef"
|
||||
@change="selMainDevice"
|
||||
:show-all-levels="false"
|
||||
placeholder="请选择抱杆设备"
|
||||
:options="deviceTypeTreeNew"
|
||||
:props="deviceTypeTreeProps"
|
||||
:disabled="mainDeviceDisabled"
|
||||
v-model="addCompleteForm.mainDevice"
|
||||
/>
|
||||
</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-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 align="center" label="操作">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button size="mini" type="danger" @click="handleDelete(row)">删 除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import {
|
||||
// getDeviceTypeTree,
|
||||
// addOrUpdateWhole,
|
||||
// searchSelectList,
|
||||
// searchSelectListById,
|
||||
// deleteById,
|
||||
// editRequest,
|
||||
// } from '@/api/store/poleConfig'
|
||||
|
||||
import { getDeviceTypeTree } from '@/api/claimAndRefund/receive'
|
||||
import {
|
||||
addCompleteSetToolsApi,
|
||||
queryCompleteSetToolsApi,
|
||||
getCompleteSetToolsApi,
|
||||
delCompleteSetToolsApi,
|
||||
} from '@/api/store/completeTools.js'
|
||||
export default {
|
||||
name: 'poleConfig',
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
showSearch: true,
|
||||
formData: {
|
||||
wholeTypeName: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
houseList: [],
|
||||
title: '新增',
|
||||
open: false,
|
||||
dialogForm: {
|
||||
parentId: '',
|
||||
mountingsValue: [],
|
||||
keyWord: '',
|
||||
},
|
||||
typeOptions: [],
|
||||
mountingsOptions: [],
|
||||
dialogList: [],
|
||||
selectList: [],
|
||||
isDetail: false,
|
||||
isEdit: false,
|
||||
total: 0,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
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()
|
||||
// 获取设备树
|
||||
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
|
||||
// this.mountingsOptions = this.getTree(data)
|
||||
// })
|
||||
},
|
||||
methods: {
|
||||
// 获取列表
|
||||
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() {
|
||||
this.queryParams.pageNum = 1
|
||||
const keyWord = this.formData.wholeTypeName?.trim() || ''
|
||||
this.getList({ keyWord })
|
||||
},
|
||||
handleSearch() {
|
||||
const keyWord = this.dialogForm.keyWord?.trim() || ''
|
||||
this.getDetail({ id: this.rowId, keyWord })
|
||||
},
|
||||
// 重置
|
||||
resetQuery() {
|
||||
this.formData.wholeTypeName = ''
|
||||
this.getList()
|
||||
},
|
||||
resetSearch() {
|
||||
this.dialogForm.wholeTypeName = ''
|
||||
this.getDetail({ id: this.rowId })
|
||||
},
|
||||
// 新增
|
||||
handleAdd() {
|
||||
// 打开新增弹窗
|
||||
this.title = '成套设备新增'
|
||||
this.addCompleteForm = {
|
||||
completeSetName: '',
|
||||
mainDevice: '',
|
||||
assortDevice: '',
|
||||
}
|
||||
this.tempList = []
|
||||
this.mainDeviceDisabled = false
|
||||
this.open = true
|
||||
},
|
||||
// 编辑
|
||||
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
|
||||
const queryParams = {
|
||||
id: row.id,
|
||||
wholeTypeName: row.wholeTypeName,
|
||||
// pageNum: 1,
|
||||
// pageSize: 99999,
|
||||
}
|
||||
const { data: res } = await queryCompleteSetToolsApi(queryParams)
|
||||
this.tempList = res
|
||||
this.open = true
|
||||
|
||||
this.$nextTick(() => {
|
||||
const mainDeviceRef = this.$refs.mainDeviceRef
|
||||
const input = mainDeviceRef.$el.querySelector('input')
|
||||
if (input) {
|
||||
input.value = this.tempList[0].deviceType
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 删除当前行
|
||||
handleDeleteRow(row) {
|
||||
this.$confirm('是否确定删除?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
delCompleteSetToolsApi({
|
||||
id: row.id,
|
||||
wholeTypeName: row.wholeTypeName,
|
||||
})
|
||||
.then((res) => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!',
|
||||
})
|
||||
|
||||
this.getList()
|
||||
})
|
||||
.catch((err) => {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '删除失败!',
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 重庆、宁夏共享成套 2024.8.30拷贝宁夏成套设备页面改造
|
||||
* 以下为弹框内操作代码逻辑
|
||||
*/
|
||||
//主体设备选择
|
||||
selMainDevice(val) {
|
||||
if (val.length < 4) {
|
||||
this.$modal.msgError('请选择第四级规格型号的数据,如未添加可以添加后再操作!')
|
||||
this.addCompleteForm.mainDevice = []
|
||||
return
|
||||
}
|
||||
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,
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
this.mainDeviceDisabled = true
|
||||
},
|
||||
// 配套设备选择
|
||||
selAssortDevice(val) {
|
||||
if (val.length < 4) {
|
||||
this.$modal.msgError('请选择第四级规格型号的数据,如未添加可以添加后再操作!')
|
||||
this.addCompleteForm.assortDevice = []
|
||||
return
|
||||
}
|
||||
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.tempList = []
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 获取 设备树结构数据
|
||||
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>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
@ -0,0 +1,547 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 首页搜索 -->
|
||||
<el-form
|
||||
:model="formData"
|
||||
ref="formData"
|
||||
size="small"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="100px"
|
||||
@submit.native.prevent
|
||||
>
|
||||
<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>
|
||||
<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-col>
|
||||
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
<!-- 列表 -->
|
||||
<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="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
|
||||
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-search" @click="onHandleView(row)">附属配件</el-button>
|
||||
<el-button type="text" icon="el-icon-delete" @click="handleDeleteRow(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="formData.pageNum"
|
||||
:limit.sync="formData.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 弹框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" v-if="open" width="80%" :close-on-click-modal="false">
|
||||
<template v-if="title !== '附件详情'">
|
||||
<el-form ref="addFormRef" :model="addCompleteForm" :rules="addCompleteRules" inline label-width="120px">
|
||||
<el-form-item label="成套设备">
|
||||
<el-cascader
|
||||
clearable
|
||||
filterable
|
||||
ref="mainDeviceRef"
|
||||
@change="selMainDevice"
|
||||
:show-all-levels="false"
|
||||
placeholder="请选择抱杆设备"
|
||||
:options="deviceTypeTreeNew"
|
||||
:props="deviceTypeTreeProps"
|
||||
:disabled="mainDeviceDisabled"
|
||||
v-model="addCompleteForm.mainDevice"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="规格型号">
|
||||
<el-select
|
||||
v-model="addCompleteForm.assortDevice"
|
||||
@change="onChangeLastType"
|
||||
clearable
|
||||
filterable
|
||||
>
|
||||
<el-option
|
||||
:key="type.typeId"
|
||||
:value="type.typeId"
|
||||
:label="type.typeName"
|
||||
v-for="type in lastTypesList"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<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 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 prop="deviceType" align="center" label="是否管理库存">
|
||||
<template slot-scope="{ row }">
|
||||
<el-tag size="mini" type="primary" v-if="row.isStorage == 1">是</el-tag>
|
||||
<el-tag size="mini" type="warning" v-if="row.isStorage == 0">否</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 操作列 -->
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button size="mini" type="danger" @click="handleDelete(row)">删 除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<el-table :data="detailsList" 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 align="center" label="数量" prop="deviceNum"> </el-table-column>
|
||||
<el-table-column prop="deviceType" align="center" label="是否管理库存">
|
||||
<template slot-scope="{ row }">
|
||||
<el-tag size="mini" type="primary" v-if="row.isStorage == 1">是</el-tag>
|
||||
<el-tag size="mini" type="warning" v-if="row.isStorage == 0">否</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import {
|
||||
// getDeviceTypeTree,
|
||||
// addOrUpdateWhole,
|
||||
// searchSelectList,
|
||||
// searchSelectListById,
|
||||
// deleteById,
|
||||
// editRequest,
|
||||
// } from '@/api/store/poleConfig'
|
||||
|
||||
import { getDeviceTypeTree } from '@/api/claimAndRefund/receive'
|
||||
import { getInfoListByTypeApi } from '@/api/store/warehousing'
|
||||
import {
|
||||
addCompleteSetToolsApi,
|
||||
queryCompleteSetToolsApi,
|
||||
getCompleteSetToolsApi,
|
||||
delCompleteSetToolsApi,
|
||||
} from '@/api/store/completeTools.js'
|
||||
export default {
|
||||
name: 'poleConfig',
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
showSearch: true,
|
||||
formData: {
|
||||
wholeTypeName: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
houseList: [],
|
||||
title: '新增',
|
||||
open: false,
|
||||
dialogForm: {
|
||||
parentId: '',
|
||||
mountingsValue: [],
|
||||
keyWord: '',
|
||||
},
|
||||
typeOptions: [],
|
||||
mountingsOptions: [],
|
||||
dialogList: [],
|
||||
selectList: [],
|
||||
isDetail: false,
|
||||
isEdit: false,
|
||||
total: 0,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
keyWord: '',
|
||||
},
|
||||
rowId: '',
|
||||
|
||||
wholeTypeName: [],
|
||||
pageContent: '成套设备新增',
|
||||
addCompleteForm: {
|
||||
completeSetName: '',
|
||||
mainDevice: '',
|
||||
assortDevice: '',
|
||||
},
|
||||
addCompleteRules: {
|
||||
mainDevice: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'change',
|
||||
message: '请选择成套设备',
|
||||
},
|
||||
],
|
||||
assortDevice: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'change',
|
||||
message: '请选择规格型号',
|
||||
},
|
||||
],
|
||||
},
|
||||
deviceTypeTreeProps: {
|
||||
multiple: false,
|
||||
value: 'id',
|
||||
},
|
||||
deviceTypeTreeNew: [], // 设备选择数据源
|
||||
tempList: [],
|
||||
mainDeviceDisabled: false,
|
||||
saveParams: {
|
||||
wholeTypeName: '', // 成套名称
|
||||
createBy: sessionStorage.getItem('userId'), // 创建人
|
||||
parentId: '', // 主体设备ID
|
||||
// companyId: 101,
|
||||
deviceInfo: [],
|
||||
},
|
||||
isEdit: false,
|
||||
deviceName: '',
|
||||
tableList: [],
|
||||
typesList: [],
|
||||
lastTypesList: [],
|
||||
lastTypeId: '',
|
||||
detailsList: [],
|
||||
parentId: '',
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
// 获取设备树
|
||||
this.getDeviceTypeTree()
|
||||
},
|
||||
methods: {
|
||||
// 获取列表
|
||||
async getList() {
|
||||
const res = await getCompleteSetToolsApi(this.formData)
|
||||
this.tableList = res.rows
|
||||
this.total = res.total
|
||||
},
|
||||
// 查询
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
const keyWord = this.formData.wholeTypeName?.trim() || ''
|
||||
this.getList({ keyWord })
|
||||
},
|
||||
handleSearch() {
|
||||
const keyWord = this.dialogForm.keyWord?.trim() || ''
|
||||
this.getDetail({ id: this.rowId, keyWord })
|
||||
},
|
||||
// 重置
|
||||
resetQuery() {
|
||||
this.formData.wholeTypeName = ''
|
||||
this.getList()
|
||||
},
|
||||
resetSearch() {
|
||||
this.dialogForm.wholeTypeName = ''
|
||||
this.getDetail({ id: this.rowId })
|
||||
},
|
||||
// 新增
|
||||
handleAdd() {
|
||||
// 打开新增弹窗
|
||||
this.title = '成套设备新增'
|
||||
this.addCompleteForm = {
|
||||
completeSetName: '',
|
||||
mainDevice: '',
|
||||
assortDevice: '',
|
||||
}
|
||||
|
||||
this.$delete(this.saveParams, 'id')
|
||||
this.tempList = []
|
||||
this.mainDeviceDisabled = false
|
||||
this.open = true
|
||||
},
|
||||
// 编辑
|
||||
async handleEdit(row) {
|
||||
this.title = '成套设备编辑'
|
||||
this.addCompleteForm.mainDevice = [row.oneId, row.towId, row.id]
|
||||
this.saveParams.id = row.id
|
||||
this.parentId = row.id
|
||||
this.saveParams.wholeTypeName = row.wholeTypeName
|
||||
this.deviceName = row.wholeTypeName
|
||||
this.mainDeviceDisabled = true
|
||||
this.isEdit = true
|
||||
|
||||
const result = await getInfoListByTypeApi({ level: '4', parentId: row.id + '' })
|
||||
this.lastTypesList = result.data
|
||||
const queryParams = {
|
||||
id: row.id,
|
||||
wholeTypeName: row.wholeTypeName,
|
||||
}
|
||||
const { data: res } = await queryCompleteSetToolsApi(queryParams)
|
||||
this.tempList = res
|
||||
this.open = true
|
||||
},
|
||||
|
||||
// 删除当前行
|
||||
handleDeleteRow(row) {
|
||||
this.$confirm('是否确定删除?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
delCompleteSetToolsApi({
|
||||
id: row.id,
|
||||
wholeTypeName: row.wholeTypeName,
|
||||
})
|
||||
.then((res) => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!',
|
||||
})
|
||||
|
||||
this.getList()
|
||||
})
|
||||
.catch((err) => {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '删除失败!',
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 重庆、宁夏共享成套 2024.8.30拷贝宁夏成套设备页面改造
|
||||
* 以下为弹框内操作代码逻辑
|
||||
*/
|
||||
//主体设备选择
|
||||
async selMainDevice(val) {
|
||||
if (val.length < 3) {
|
||||
this.$modal.msgError('请选择第三级设备类型,如未添加可以添加后再操作!')
|
||||
this.addCompleteForm.mainDevice = []
|
||||
return
|
||||
}
|
||||
this.$message.closeAll()
|
||||
const checkNode = this.$refs['mainDeviceRef'].getCheckedNodes()
|
||||
|
||||
const label = checkNode[0].label
|
||||
const value = checkNode[0].value
|
||||
this.deviceName = label
|
||||
this.parentId = value
|
||||
const res = await getInfoListByTypeApi({ level: '4', parentId: value + '' })
|
||||
this.lastTypesList = res.data
|
||||
this.tempList = []
|
||||
this.addCompleteForm.assortDevice = ''
|
||||
},
|
||||
// 配套设备选择
|
||||
selAssortDevice(val) {
|
||||
if (val.length < 4) {
|
||||
this.$modal.msgError('请选择第四级规格型号的数据,如未添加可以添加后再操作!')
|
||||
this.addCompleteForm.assortDevice = []
|
||||
return
|
||||
}
|
||||
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 (this.tempList.length === 0) {
|
||||
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) {}
|
||||
|
||||
this.saveParams.wholeTypeName = this.deviceName
|
||||
this.saveParams.parentId = this.parentId
|
||||
|
||||
this.saveParams.deviceInfo = this.tempList
|
||||
const res = await addCompleteSetToolsApi(this.saveParams)
|
||||
|
||||
if (res.code == 200) {
|
||||
this.$message.success(this.title === '成套设备新增' ? '新增成功!' : '修改成功!')
|
||||
this.open = false
|
||||
this.tempList = []
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 获取 设备树结构数据
|
||||
async getDeviceTypeTree() {
|
||||
const params = {
|
||||
level: 3,
|
||||
}
|
||||
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) {}
|
||||
},
|
||||
|
||||
// 规格型号的change事件
|
||||
onChangeLastType(val) {
|
||||
const typeLabel = this.lastTypesList.find((e) => e.typeId === val)
|
||||
|
||||
const { typeName, isStorage } = typeLabel
|
||||
const assortDeviceObj = {
|
||||
deviceType: typeName, // 设备名称
|
||||
deviceTypeId: val, // 设备Id
|
||||
deviceNum: '', // 数量
|
||||
deviceAscription: '配套设备', // 所属类型
|
||||
ascriptionType: 2, // 所属类型 1 主体设备 2 配套设备
|
||||
typeName: this.deviceName,
|
||||
isStorage,
|
||||
}
|
||||
|
||||
const isRepeat = this.tempList.some((e) => e.deviceTypeId === assortDeviceObj.deviceTypeId)
|
||||
|
||||
if (isRepeat) {
|
||||
this.$message.error('该设备已添加,不可重复添加!')
|
||||
return
|
||||
} else {
|
||||
this.tempList.push(assortDeviceObj)
|
||||
}
|
||||
},
|
||||
|
||||
// 查看附属配件
|
||||
async onHandleView(row) {
|
||||
this.title = '附件详情'
|
||||
|
||||
this.saveParams.id = row.id
|
||||
const queryParams = {
|
||||
id: row.id,
|
||||
wholeTypeName: row.wholeTypeName,
|
||||
}
|
||||
const { data: res } = await queryCompleteSetToolsApi(queryParams)
|
||||
this.detailsList = res
|
||||
this.open = true
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
@ -10,17 +10,36 @@
|
|||
label-width="100px"
|
||||
@submit.native.prevent
|
||||
>
|
||||
<el-form-item label="成套设备" prop="wholeTypeName">
|
||||
<el-form-item label="成套设备名称" prop="wholeTypeName">
|
||||
<el-input
|
||||
v-model="formData.wholeTypeName"
|
||||
placeholder="请输入成套设备"
|
||||
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="请输入关键字"
|
||||
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="请输入关键字"
|
||||
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>
|
||||
|
|
@ -45,9 +64,9 @@
|
|||
:index="indexContinuation(queryParams.pageNum, queryParams.pageSize)"
|
||||
>
|
||||
</el-table-column>
|
||||
<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="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">
|
||||
|
|
@ -59,7 +78,6 @@
|
|||
>查看</el-button
|
||||
> -->
|
||||
<el-button type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button type="text" icon="el-icon-search" @click="onHandleView(row)">附属配件</el-button>
|
||||
<el-button type="text" icon="el-icon-delete" @click="handleDeleteRow(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -75,88 +93,72 @@
|
|||
|
||||
<!-- 弹框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" v-if="open" width="80%" :close-on-click-modal="false">
|
||||
<template v-if="title !== '附件详情'">
|
||||
<el-form ref="addFormRef" :model="addCompleteForm" :rules="addCompleteRules" inline label-width="120px">
|
||||
<el-form-item label="成套设备">
|
||||
<el-cascader
|
||||
clearable
|
||||
filterable
|
||||
ref="mainDeviceRef"
|
||||
@change="selMainDevice"
|
||||
:show-all-levels="false"
|
||||
placeholder="请选择抱杆设备"
|
||||
:options="deviceTypeTreeNew"
|
||||
:props="deviceTypeTreeProps"
|
||||
:disabled="mainDeviceDisabled"
|
||||
v-model="addCompleteForm.mainDevice"
|
||||
<el-form ref="addFormRef" :model="addCompleteForm" :rules="addCompleteRules" inline label-width="120px">
|
||||
<el-form-item label="成套名称" prop="completeSetName">
|
||||
<el-input v-model="addCompleteForm.completeSetName" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="抱杆设备" prop="mainDevice" class="is-required">
|
||||
<el-cascader
|
||||
clearable
|
||||
filterable
|
||||
ref="mainDeviceRef"
|
||||
@change="selMainDevice"
|
||||
:show-all-levels="false"
|
||||
placeholder="请选择抱杆设备"
|
||||
:options="deviceTypeTreeNew"
|
||||
:props="deviceTypeTreeProps"
|
||||
:disabled="mainDeviceDisabled"
|
||||
v-model="addCompleteForm.mainDevice"
|
||||
/>
|
||||
</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-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"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="规格型号">
|
||||
<el-select
|
||||
v-model="addCompleteForm.assortDevice"
|
||||
@change="onChangeLastType"
|
||||
clearable
|
||||
filterable
|
||||
>
|
||||
<el-option
|
||||
:key="type.typeId"
|
||||
:value="type.typeId"
|
||||
:label="type.typeName"
|
||||
v-for="type in lastTypesList"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<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 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 prop="deviceType" align="center" label="是否管理库存">
|
||||
<template slot-scope="{ row }">
|
||||
<el-tag size="mini" type="primary" v-if="row.isStorage == 1">是</el-tag>
|
||||
<el-tag size="mini" type="warning" v-if="row.isStorage == 0">否</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 操作列 -->
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button size="mini" type="danger" @click="handleDelete(row)">删 除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<el-table :data="detailsList" 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 align="center" label="数量" prop="deviceNum"> </el-table-column>
|
||||
<el-table-column prop="deviceType" align="center" label="是否管理库存">
|
||||
<template slot-scope="{ row }">
|
||||
<el-tag size="mini" type="primary" v-if="row.isStorage == 1">是</el-tag>
|
||||
<el-tag size="mini" type="warning" v-if="row.isStorage == 0">否</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="是否管理库存">
|
||||
<template slot-scope="{ row }">
|
||||
<el-tag size="mini" type="primary" v-if="row.isStorage == 1">是</el-tag>
|
||||
<el-tag size="mini" type="warning" v-if="row.isStorage == 0">否</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 操作列 -->
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button size="mini" type="danger" @click="handleDelete(row)">删 除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -172,7 +174,6 @@
|
|||
// } from '@/api/store/poleConfig'
|
||||
|
||||
import { getDeviceTypeTree } from '@/api/claimAndRefund/receive'
|
||||
import { getInfoListByTypeApi } from '@/api/store/warehousing'
|
||||
import {
|
||||
addCompleteSetToolsApi,
|
||||
queryCompleteSetToolsApi,
|
||||
|
|
@ -220,20 +221,27 @@ export default {
|
|||
assortDevice: '',
|
||||
},
|
||||
addCompleteRules: {
|
||||
mainDevice: [
|
||||
completeSetName: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'change',
|
||||
message: '请选择成套设备',
|
||||
trigger: 'blur',
|
||||
message: '请输入成套名称',
|
||||
},
|
||||
],
|
||||
assortDevice: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'change',
|
||||
message: '请选择规格型号',
|
||||
max: 40,
|
||||
message: '长度不能超过40个字符',
|
||||
},
|
||||
],
|
||||
// mainDevice: [
|
||||
// {
|
||||
// required: true,
|
||||
// },
|
||||
// ],
|
||||
// assortDevice: [
|
||||
// {
|
||||
// required: true,
|
||||
// },
|
||||
// ],
|
||||
},
|
||||
deviceTypeTreeProps: {
|
||||
multiple: false,
|
||||
|
|
@ -252,24 +260,40 @@ export default {
|
|||
isEdit: false,
|
||||
deviceName: '',
|
||||
tableList: [],
|
||||
typesList: [],
|
||||
lastTypesList: [],
|
||||
lastTypeId: '',
|
||||
detailsList: [],
|
||||
parentId: '',
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
// 获取设备树
|
||||
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
|
||||
// this.mountingsOptions = this.getTree(data)
|
||||
// })
|
||||
},
|
||||
methods: {
|
||||
// 获取列表
|
||||
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() {
|
||||
|
|
@ -299,8 +323,6 @@ export default {
|
|||
mainDevice: '',
|
||||
assortDevice: '',
|
||||
}
|
||||
|
||||
this.$delete(this.saveParams, 'id')
|
||||
this.tempList = []
|
||||
this.mainDeviceDisabled = false
|
||||
this.open = true
|
||||
|
|
@ -308,23 +330,28 @@ export default {
|
|||
// 编辑
|
||||
async handleEdit(row) {
|
||||
this.title = '成套设备编辑'
|
||||
this.addCompleteForm.mainDevice = [row.oneId, row.towId, row.id]
|
||||
this.addCompleteForm.completeSetName = row.wholeTypeName
|
||||
this.addCompleteForm.mainDevice = row.deviceTypeId
|
||||
this.saveParams.id = row.id
|
||||
this.parentId = row.id
|
||||
this.saveParams.wholeTypeName = row.wholeTypeName
|
||||
this.deviceName = row.wholeTypeName
|
||||
this.mainDeviceDisabled = true
|
||||
this.isEdit = true
|
||||
|
||||
const result = await getInfoListByTypeApi({ level: '4', parentId: row.id + '' })
|
||||
this.lastTypesList = result.data
|
||||
const queryParams = {
|
||||
id: row.id,
|
||||
wholeTypeName: row.wholeTypeName,
|
||||
// pageNum: 1,
|
||||
// pageSize: 99999,
|
||||
}
|
||||
const { data: res } = await queryCompleteSetToolsApi(queryParams)
|
||||
this.tempList = res
|
||||
this.open = true
|
||||
|
||||
this.$nextTick(() => {
|
||||
const mainDeviceRef = this.$refs.mainDeviceRef
|
||||
const input = mainDeviceRef.$el.querySelector('input')
|
||||
if (input) {
|
||||
input.value = this.tempList[0].deviceType
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 删除当前行
|
||||
|
|
@ -362,23 +389,42 @@ export default {
|
|||
* 以下为弹框内操作代码逻辑
|
||||
*/
|
||||
//主体设备选择
|
||||
async selMainDevice(val) {
|
||||
if (val.length < 3) {
|
||||
this.$modal.msgError('请选择第三级设备类型,如未添加可以添加后再操作!')
|
||||
selMainDevice(val) {
|
||||
if (val.length < 4) {
|
||||
this.$modal.msgError('请选择第四级规格型号的数据,如未添加可以添加后再操作!')
|
||||
this.addCompleteForm.mainDevice = []
|
||||
return
|
||||
}
|
||||
this.$message.closeAll()
|
||||
const checkNode = this.$refs['mainDeviceRef'].getCheckedNodes()
|
||||
this.recursionGetDeviceName(this.deviceTypeTreeNew, val[val.length - 2])
|
||||
if (checkNode.length < 1) return
|
||||
|
||||
const label = checkNode[0].label
|
||||
const value = checkNode[0].value
|
||||
this.deviceName = label
|
||||
this.parentId = value
|
||||
const res = await getInfoListByTypeApi({ level: '4', parentId: value + '' })
|
||||
this.lastTypesList = res.data
|
||||
this.tempList = []
|
||||
this.addCompleteForm.assortDevice = ''
|
||||
this.addCompleteForm.completeSetName = this.deviceName + '-' + checkNode[0].label
|
||||
const mainDeviceObj = {
|
||||
deviceType: checkNode[0].label, // 设备型号
|
||||
deviceTypeId: val[val.length - 1], // 设备Id
|
||||
deviceNum: '', // 数量
|
||||
deviceAscription: '抱杆设备', // 所属类型
|
||||
ascriptionType: 1, // 所属类型 1 主体设备 2 配套设备
|
||||
typeName: this.deviceName,
|
||||
isStorage: checkNode[0].isStorage,
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
this.mainDeviceDisabled = true
|
||||
},
|
||||
// 配套设备选择
|
||||
selAssortDevice(val) {
|
||||
|
|
@ -394,7 +440,7 @@ export default {
|
|||
if (checkNode.length < 1) return
|
||||
|
||||
const assortDeviceObj = {
|
||||
deviceType: checkNode[0].label, // 设备名称 (规格型号的名称)
|
||||
deviceType: checkNode[0].label, // 设备名称
|
||||
deviceTypeId: val[val.length - 1], // 设备Id
|
||||
deviceNum: '', // 数量
|
||||
deviceAscription: '配套设备', // 所属类型
|
||||
|
|
@ -438,13 +484,21 @@ export default {
|
|||
this.$refs.addFormRef.validate(async (valid) => {
|
||||
if (valid) {
|
||||
let isNum = false
|
||||
// const isMainDevice = this.tempList.some((e) => e.ascriptionType === 1)
|
||||
const isMainDevice = this.tempList.some((e) => e.ascriptionType === 1)
|
||||
|
||||
if (this.tempList.length === 0) {
|
||||
this.$message.error('请添加设备!')
|
||||
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)) {
|
||||
|
|
@ -457,14 +511,16 @@ export default {
|
|||
})
|
||||
} catch (error) {}
|
||||
|
||||
this.saveParams.wholeTypeName = this.deviceName
|
||||
this.saveParams.parentId = this.parentId
|
||||
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.$message.success(!this.title === '成套设备新增' ? '新增成功!' : '修改成功!')
|
||||
this.open = false
|
||||
this.tempList = []
|
||||
this.getList()
|
||||
|
|
@ -476,7 +532,7 @@ export default {
|
|||
// 获取 设备树结构数据
|
||||
async getDeviceTypeTree() {
|
||||
const params = {
|
||||
level: 3,
|
||||
level: 4,
|
||||
}
|
||||
const res = await getDeviceTypeTree(params)
|
||||
this.deviceTypeTreeNew = res.data
|
||||
|
|
@ -501,45 +557,6 @@ export default {
|
|||
})
|
||||
} catch (error) {}
|
||||
},
|
||||
|
||||
// 规格型号的change事件
|
||||
onChangeLastType(val) {
|
||||
const typeLabel = this.lastTypesList.find((e) => e.typeId === val)
|
||||
|
||||
const { typeName, isStorage } = typeLabel
|
||||
const assortDeviceObj = {
|
||||
deviceType: typeName, // 设备名称
|
||||
deviceTypeId: val, // 设备Id
|
||||
deviceNum: '', // 数量
|
||||
deviceAscription: '配套设备', // 所属类型
|
||||
ascriptionType: 2, // 所属类型 1 主体设备 2 配套设备
|
||||
typeName: this.deviceName,
|
||||
isStorage,
|
||||
}
|
||||
|
||||
const isRepeat = this.tempList.some((e) => e.deviceTypeId === assortDeviceObj.deviceTypeId)
|
||||
|
||||
if (isRepeat) {
|
||||
this.$message.error('该设备已添加,不可重复添加!')
|
||||
return
|
||||
} else {
|
||||
this.tempList.push(assortDeviceObj)
|
||||
}
|
||||
},
|
||||
|
||||
// 查看附属配件
|
||||
async onHandleView(row) {
|
||||
this.title = '附件详情'
|
||||
|
||||
this.saveParams.id = row.id
|
||||
const queryParams = {
|
||||
id: row.id,
|
||||
wholeTypeName: row.wholeTypeName,
|
||||
}
|
||||
const { data: res } = await queryCompleteSetToolsApi(queryParams)
|
||||
this.detailsList = res
|
||||
this.open = true
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
265
vue.config.js
265
vue.config.js
|
|
@ -2,7 +2,7 @@
|
|||
const path = require('path')
|
||||
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, dir)
|
||||
return path.join(__dirname, dir)
|
||||
}
|
||||
|
||||
const CompressionPlugin = require('compression-webpack-plugin')
|
||||
|
|
@ -16,142 +16,143 @@ const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
|||
// 这里只列一部分,具体配置参考文档
|
||||
|
||||
module.exports = {
|
||||
// 部署生产环境和开发环境下的URL。
|
||||
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
|
||||
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
|
||||
publicPath: process.env.VUE_APP_ENV === 'production-nw' ? '/gl' : '/', ///gl/
|
||||
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
|
||||
outputDir: 'dist',
|
||||
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
|
||||
assetsDir: 'static',
|
||||
// 是否开启eslint保存检测,有效值:ture | false | 'error'
|
||||
lintOnSave: process.env.NODE_ENV === 'development',
|
||||
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
|
||||
productionSourceMap: false,
|
||||
// webpack-dev-server 相关配置
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
port: port,
|
||||
open: true,
|
||||
proxy: {
|
||||
[process.env.VUE_APP_BASE_API]: {
|
||||
// target: `http://112.29.103.165:21626`, //线上环境-重庆
|
||||
// target: `http://112.29.103.165:21624`,//线上环境-宁夏 打包前放开数据大屏的路由
|
||||
// target: `http://192.168.0.56:39080`, //测试环境
|
||||
// target: `http://1.12.248.179:23028`,//线上环境-南网
|
||||
// target: `https://test-cc.zhgkxt.com`,//线上环境-南网
|
||||
// target: `https://z.csgmall.com.cn`,
|
||||
// 部署生产环境和开发环境下的URL。
|
||||
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
|
||||
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
|
||||
publicPath: process.env.VUE_APP_ENV === 'production-nw' ? '/gl' : '/', ///gl/
|
||||
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
|
||||
outputDir: 'dist',
|
||||
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
|
||||
assetsDir: 'static',
|
||||
// 是否开启eslint保存检测,有效值:ture | false | 'error'
|
||||
lintOnSave: process.env.NODE_ENV === 'development',
|
||||
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
|
||||
productionSourceMap: false,
|
||||
// webpack-dev-server 相关配置
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
port: port,
|
||||
open: true,
|
||||
proxy: {
|
||||
[process.env.VUE_APP_BASE_API]: {
|
||||
// target: `http://112.29.103.165:21626`, //线上环境-重庆
|
||||
// target: `http://112.29.103.165:21624`,//线上环境-宁夏 打包前放开数据大屏的路由
|
||||
// target: `http://192.168.0.56:39080`, //测试环境
|
||||
// target: `http://1.12.248.179:23028`,//线上环境-南网
|
||||
// target: `https://test-cc.zhgkxt.com`,//线上环境-南网
|
||||
// target: `https://z.csgmall.com.cn`,
|
||||
|
||||
// target: `http://192.168.0.15:39080`, //韩
|
||||
target: `http://192.168.0.133:39080`, //超
|
||||
// target: `http://192.168.0.15:39080`, //韩
|
||||
target: `http://192.168.0.133:39080`, //超
|
||||
// target: `http://192.168.2.127:39080`, //超
|
||||
|
||||
// target: `http://192.168.2.74:49080`, //旭/
|
||||
// target: `http://192.168.2.17:39080`, //帅
|
||||
// target: `http://192.168.0.60:39080`, //福
|
||||
// target: `http://192.168.0.96:39080`, //马
|
||||
// target: `http://192.168.2.74:49080`, //旭/
|
||||
// target: `http://192.168.2.17:39080`, //帅
|
||||
// target: `http://192.168.0.60:39080`, //福
|
||||
// target: `http://192.168.0.96:39080`, //马
|
||||
|
||||
//******** 注意事项 ********* */
|
||||
//1.全局替换qrUrl二维码扫码提供的网址-发布服务器的地址target;
|
||||
//更改 utils/globalUrl.js 内qrUrl地址
|
||||
//2.打开view文件夹根目录dashboard.vue 更换大屏项目发布的跳转地址;
|
||||
//3.只有南网项目产线gl发布打包时候需要注意:
|
||||
// 将 publicPath:'static' 改为 '/gl/',还有env.development和env.production中的VUE_APP_BASE_API改为'/gl/dev-api';
|
||||
// router/indx.js文件中的base放开
|
||||
// 登录跳转地址从/login换成/gl/login 3处;
|
||||
//4. 重庆环境的时候 领料管理线上菜单与宁夏不同需要根据环境在线上菜单管理中修改组件路径
|
||||
//******** 注意事项 ********* */
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_API]: '',
|
||||
},
|
||||
},
|
||||
//******** 注意事项 ********* */
|
||||
//1.全局替换qrUrl二维码扫码提供的网址-发布服务器的地址target;
|
||||
//更改 utils/globalUrl.js 内qrUrl地址
|
||||
//2.打开view文件夹根目录dashboard.vue 更换大屏项目发布的跳转地址;
|
||||
//3.只有南网项目产线gl发布打包时候需要注意:
|
||||
// 将 publicPath:'static' 改为 '/gl/',还有env.development和env.production中的VUE_APP_BASE_API改为'/gl/dev-api';
|
||||
// router/indx.js文件中的base放开
|
||||
// 登录跳转地址从/login换成/gl/login 3处;
|
||||
//4. 重庆环境的时候 领料管理线上菜单与宁夏不同需要根据环境在线上菜单管理中修改组件路径
|
||||
//******** 注意事项 ********* */
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_API]: '',
|
||||
},
|
||||
disableHostCheck: true,
|
||||
},
|
||||
},
|
||||
css: {
|
||||
loaderOptions: {
|
||||
sass: {
|
||||
sassOptions: { outputStyle: 'expanded' },
|
||||
},
|
||||
disableHostCheck: true,
|
||||
},
|
||||
css: {
|
||||
loaderOptions: {
|
||||
sass: {
|
||||
sassOptions: { outputStyle: 'expanded' },
|
||||
},
|
||||
},
|
||||
},
|
||||
configureWebpack: {
|
||||
name: name,
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve('src'),
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
// http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
|
||||
new CompressionPlugin({
|
||||
cache: false, // 不启用文件缓存
|
||||
test: /\.(js|css|html)?$/i, // 压缩文件格式
|
||||
filename: '[path].gz[query]', // 压缩后的文件名
|
||||
algorithm: 'gzip', // 使用gzip压缩
|
||||
minRatio: 0.8, // 压缩率小于1才会压缩
|
||||
}),
|
||||
],
|
||||
},
|
||||
chainWebpack(config) {
|
||||
config.plugins.delete('preload') // TODO: need test
|
||||
config.plugins.delete('prefetch') // TODO: need test
|
||||
|
||||
// set svg-sprite-loader
|
||||
config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end()
|
||||
config.module
|
||||
.rule('icons')
|
||||
.test(/\.svg$/)
|
||||
.include.add(resolve('src/assets/icons'))
|
||||
.end()
|
||||
.use('svg-sprite-loader')
|
||||
.loader('svg-sprite-loader')
|
||||
.options({
|
||||
symbolId: 'icon-[name]',
|
||||
})
|
||||
.end()
|
||||
|
||||
config.when(process.env.NODE_ENV !== 'development', (config) => {
|
||||
config
|
||||
.plugin('ScriptExtHtmlWebpackPlugin')
|
||||
.after('html')
|
||||
.use('script-ext-html-webpack-plugin', [
|
||||
{
|
||||
// `runtime` must same as runtimeChunk name. default is `runtime`
|
||||
inline: /runtime\..*\.js$/,
|
||||
},
|
||||
])
|
||||
.end()
|
||||
|
||||
config.optimization.splitChunks({
|
||||
chunks: 'all',
|
||||
cacheGroups: {
|
||||
libs: {
|
||||
name: 'chunk-libs',
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
priority: 10,
|
||||
chunks: 'initial', // only package third parties that are initially dependent
|
||||
},
|
||||
elementUI: {
|
||||
name: 'chunk-elementUI', // split elementUI into a single package
|
||||
test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
|
||||
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
|
||||
},
|
||||
commons: {
|
||||
name: 'chunk-commons',
|
||||
test: resolve('src/components'), // can customize your rules
|
||||
minChunks: 3, // minimum common number
|
||||
priority: 5,
|
||||
reuseExistingChunk: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
configureWebpack: {
|
||||
name: name,
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve('src'),
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
// http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
|
||||
new CompressionPlugin({
|
||||
cache: false, // 不启用文件缓存
|
||||
test: /\.(js|css|html)?$/i, // 压缩文件格式
|
||||
filename: '[path].gz[query]', // 压缩后的文件名
|
||||
algorithm: 'gzip', // 使用gzip压缩
|
||||
minRatio: 0.8, // 压缩率小于1才会压缩
|
||||
}),
|
||||
],
|
||||
},
|
||||
chainWebpack(config) {
|
||||
config.plugins.delete('preload') // TODO: need test
|
||||
config.plugins.delete('prefetch') // TODO: need test
|
||||
})
|
||||
|
||||
// set svg-sprite-loader
|
||||
config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end()
|
||||
config.module
|
||||
.rule('icons')
|
||||
.test(/\.svg$/)
|
||||
.include.add(resolve('src/assets/icons'))
|
||||
.end()
|
||||
.use('svg-sprite-loader')
|
||||
.loader('svg-sprite-loader')
|
||||
.options({
|
||||
symbolId: 'icon-[name]',
|
||||
})
|
||||
.end()
|
||||
|
||||
config.when(process.env.NODE_ENV !== 'development', (config) => {
|
||||
config
|
||||
.plugin('ScriptExtHtmlWebpackPlugin')
|
||||
.after('html')
|
||||
.use('script-ext-html-webpack-plugin', [
|
||||
{
|
||||
// `runtime` must same as runtimeChunk name. default is `runtime`
|
||||
inline: /runtime\..*\.js$/,
|
||||
},
|
||||
])
|
||||
.end()
|
||||
|
||||
config.optimization.splitChunks({
|
||||
chunks: 'all',
|
||||
cacheGroups: {
|
||||
libs: {
|
||||
name: 'chunk-libs',
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
priority: 10,
|
||||
chunks: 'initial', // only package third parties that are initially dependent
|
||||
},
|
||||
elementUI: {
|
||||
name: 'chunk-elementUI', // split elementUI into a single package
|
||||
test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
|
||||
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
|
||||
},
|
||||
commons: {
|
||||
name: 'chunk-commons',
|
||||
test: resolve('src/components'), // can customize your rules
|
||||
minChunks: 3, // minimum common number
|
||||
priority: 5,
|
||||
reuseExistingChunk: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
config.optimization.runtimeChunk('single'),
|
||||
{
|
||||
from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件
|
||||
to: './', //到根目录下
|
||||
}
|
||||
})
|
||||
},
|
||||
config.optimization.runtimeChunk('single'),
|
||||
{
|
||||
from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件
|
||||
to: './', //到根目录下
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue