基础分类修改
This commit is contained in:
@@ -72,4 +72,11 @@ export function getClassTable(params) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getClass, getClassSuperior, getClassType, getClassTable, getType, queryClassById }
|
||||
export function getClassName() {
|
||||
return request({
|
||||
url: 'api/Classstandard/getClassName',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getClass, getClassSuperior, getClassType, getClassTable, getType, queryClassById, getClassName }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {download, initData} from '@/api/data'
|
||||
import {downloadFile, parseTime} from '@/utils/index'
|
||||
import { download, initData } from '@/api/data'
|
||||
import { downloadFile, parseTime } from '@/utils/index'
|
||||
import Vue from 'vue'
|
||||
|
||||
/**
|
||||
@@ -70,6 +70,7 @@ function CRUD(options) {
|
||||
status: {
|
||||
add: CRUD.STATUS.NORMAL,
|
||||
edit: CRUD.STATUS.NORMAL,
|
||||
view: CRUD.STATUS.NORMAL,
|
||||
// 添加或编辑状态
|
||||
get cu() {
|
||||
if (this.add === CRUD.STATUS.NORMAL && this.edit === CRUD.STATUS.NORMAL) {
|
||||
@@ -83,7 +84,7 @@ function CRUD(options) {
|
||||
},
|
||||
// 标题
|
||||
get title() {
|
||||
return this.add > CRUD.STATUS.NORMAL ? `新增${crud.title}` : this.edit > CRUD.STATUS.NORMAL ? `编辑${crud.title}` : crud.title
|
||||
return this.add > CRUD.STATUS.NORMAL ? `新增${crud.title}` : this.edit > CRUD.STATUS.NORMAL ? `编辑${crud.title}` : this.view > CRUD.STATUS.NORMAL ? `${crud.title}详情` : crud.title
|
||||
}
|
||||
},
|
||||
msg: {
|
||||
@@ -163,14 +164,40 @@ function CRUD(options) {
|
||||
* 格式化数据,保留0位小数
|
||||
*/
|
||||
formatNum0(row, column) {
|
||||
if (!row[column.property]) {
|
||||
return 0
|
||||
}
|
||||
return parseFloat(row[column.property]).toFixed(0)
|
||||
},
|
||||
/**
|
||||
* 格式化数据,保留2位小数
|
||||
*/
|
||||
formatNum2(row, column) {
|
||||
if (!row[column.property]) {
|
||||
return 0
|
||||
}
|
||||
return parseFloat(row[column.property]).toFixed(2)
|
||||
},
|
||||
|
||||
/**
|
||||
* 格式化数据,保留3位小数
|
||||
*/
|
||||
formatNum3(row, column) {
|
||||
if (!row[column.property]) {
|
||||
return 0
|
||||
}
|
||||
return parseFloat(row[column.property]).toFixed(3)
|
||||
},
|
||||
|
||||
/**
|
||||
* 质检格式化数据,保留4位小数
|
||||
*/
|
||||
formatQlNum4(row, column) {
|
||||
if (!row[column.property]) {
|
||||
return ''
|
||||
}
|
||||
return parseFloat(row[column.property]).toFixed(4)
|
||||
},
|
||||
/**
|
||||
* 启动添加
|
||||
*/
|
||||
@@ -184,11 +211,13 @@ function CRUD(options) {
|
||||
callVmHook(crud, CRUD.HOOK.afterToCU, crud.form)
|
||||
},
|
||||
/**
|
||||
* 启动复制新增
|
||||
* @param {*} data 数据项
|
||||
* 启动添加 可携带参数
|
||||
*/
|
||||
toCopy(data) {
|
||||
toAddAndData(data) {
|
||||
crud.resetForm(JSON.parse(JSON.stringify(data)))
|
||||
if (!(callVmHook(crud, CRUD.HOOK.beforeToAdd, crud.form) && callVmHook(crud, CRUD.HOOK.beforeToCU, crud.form))) {
|
||||
return
|
||||
}
|
||||
crud.status.add = CRUD.STATUS.PREPARED
|
||||
callVmHook(crud, CRUD.HOOK.afterToAdd, crud.form)
|
||||
callVmHook(crud, CRUD.HOOK.afterToCU, crud.form)
|
||||
@@ -207,6 +236,17 @@ function CRUD(options) {
|
||||
callVmHook(crud, CRUD.HOOK.afterToEdit, crud.form)
|
||||
callVmHook(crud, CRUD.HOOK.afterToCU, crud.form)
|
||||
},
|
||||
/**
|
||||
* 查询详情
|
||||
* @param {*} data 数据项
|
||||
*/
|
||||
toView(data) {
|
||||
crud.params.optRow = data
|
||||
crud.resetForm(JSON.parse(JSON.stringify(data)))
|
||||
crud.status.view = CRUD.STATUS.PREPARED
|
||||
crud.getDataStatus(crud.getDataId(data)).view = CRUD.STATUS.PREPARED
|
||||
callVmHook(crud, CRUD.HOOK.afterToView, crud.form)
|
||||
},
|
||||
/**
|
||||
* 启动删除
|
||||
* @param {*} data 数据项
|
||||
@@ -225,21 +265,14 @@ function CRUD(options) {
|
||||
crud.getDataStatus(crud.getDataId(data)).delete = CRUD.STATUS.NORMAL
|
||||
callVmHook(crud, CRUD.HOOK.afterDeleteCancel, data)
|
||||
},
|
||||
/**
|
||||
* 查询详情
|
||||
* @param {*} data 数据项
|
||||
*/
|
||||
toView(data) {
|
||||
crud.params.optRow = data
|
||||
crud.resetForm(JSON.parse(JSON.stringify(data)))
|
||||
crud.status.view = CRUD.STATUS.PREPARED
|
||||
crud.getDataStatus(crud.getDataId(data)).view = CRUD.STATUS.PREPARED
|
||||
callVmHook(crud, CRUD.HOOK.afterToView, crud.form)
|
||||
},
|
||||
/**
|
||||
* 取消新增/编辑
|
||||
*/
|
||||
cancelCU() {
|
||||
cancelCU(formName) {
|
||||
if (formName instanceof PointerEvent) {
|
||||
formName = 'form'
|
||||
}
|
||||
|
||||
const addStatus = crud.status.add
|
||||
const editStatus = crud.status.edit
|
||||
const viewStatus = crud.status.view
|
||||
@@ -267,18 +300,21 @@ function CRUD(options) {
|
||||
callVmHook(crud, CRUD.HOOK.afterEditCancel, crud.form)
|
||||
}
|
||||
// 清除表单验证
|
||||
if (crud.findVM('form').$refs['form']) {
|
||||
crud.findVM('form').$refs['form'].clearValidate()
|
||||
if (crud.findVM('form').$refs[formName]) {
|
||||
crud.findVM('form').$refs[formName].clearValidate()
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 提交新增/编辑
|
||||
*/
|
||||
submitCU() {
|
||||
submitCU(formName) {
|
||||
if (formName instanceof PointerEvent) {
|
||||
formName = 'form'
|
||||
}
|
||||
if (!callVmHook(crud, CRUD.HOOK.beforeValidateCU)) {
|
||||
return
|
||||
}
|
||||
crud.findVM('form').$refs['form'].validate(valid => {
|
||||
crud.findVM('form').$refs[formName].validate(valid => {
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
@@ -319,7 +355,6 @@ function CRUD(options) {
|
||||
return
|
||||
}
|
||||
crud.status.edit = CRUD.STATUS.PROCESSING
|
||||
debugger
|
||||
crud.crudMethod.edit(crud.form).then(() => {
|
||||
crud.status.edit = CRUD.STATUS.NORMAL
|
||||
crud.getDataStatus(crud.getDataId(crud.form)).edit = CRUD.STATUS.NORMAL
|
||||
@@ -397,7 +432,7 @@ function CRUD(options) {
|
||||
/**
|
||||
* 获取查询参数
|
||||
*/
|
||||
getQueryParams: function () {
|
||||
getQueryParams: function() {
|
||||
// 清除参数无值的情况
|
||||
Object.keys(crud.query).length !== 0 && Object.keys(crud.query).forEach(item => {
|
||||
if (crud.query[item] === null || crud.query[item] === '') crud.query[item] = undefined
|
||||
@@ -465,8 +500,10 @@ function CRUD(options) {
|
||||
}
|
||||
}
|
||||
// add by ghl 2020-10-04 页面重复添加信息时,下拉框的校验会存在,需要找工取消
|
||||
if (crud.findVM('form').$refs['form']) {
|
||||
crud.findVM('form').$refs['form'].clearValidate()
|
||||
let form_ref = 'form'
|
||||
if (crudFrom.form_ref) form_ref = crudFrom.form_ref
|
||||
if (crud.findVM('form').$refs[form_ref]) {
|
||||
crud.findVM('form').$refs[form_ref].clearValidate()
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -892,7 +929,8 @@ CRUD.HOOK = {
|
||||
/** 提交 - 之后 */
|
||||
afterSubmit: 'afterCrudSubmitCU',
|
||||
afterAddError: 'afterCrudAddError',
|
||||
afterEditError: 'afterCrudEditError'
|
||||
afterEditError: 'afterCrudEditError',
|
||||
afterToView: 'afterToView'
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,33 +2,49 @@
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-row>
|
||||
<el-col :span="9">
|
||||
<span style="line-height:36px;text-align: center">基础分类:</span>
|
||||
</el-col>
|
||||
<el-col :span="15">
|
||||
<el-select
|
||||
v-model="query.base_data_type"
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dict.base_data"
|
||||
:key="item.id"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<rrOperation />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="90px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="分类名称">
|
||||
<el-select
|
||||
v-model="query.class_code"
|
||||
placeholder="请选择分类名称"
|
||||
clearable
|
||||
filterable
|
||||
size="mini"
|
||||
class="filter-item"
|
||||
style="width: 185px;"
|
||||
@change="hand">
|
||||
<el-option
|
||||
v-for="item in classNames"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<rrOperation :crud="crud" />
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<crudOperation :permission="permission">
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="success"
|
||||
icon="el-icon-s-operation"
|
||||
@click="ToExpandall"
|
||||
>
|
||||
全部展开
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
@@ -44,21 +60,6 @@
|
||||
<el-form-item label="分类名称" prop="class_name">
|
||||
<el-input v-model="form.class_name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="基础分类" prop="base_data_type">
|
||||
<el-select
|
||||
v-model="form.base_data_type"
|
||||
placeholder=""
|
||||
@change="dataTypeChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in dict.base_data"
|
||||
:key="item.id"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<span style="color: #C0C0C0;margin-left: 10px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="简要描述" prop="class_desc">
|
||||
<el-input v-model="form.class_desc" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
@@ -105,17 +106,20 @@
|
||||
<el-table-column
|
||||
v-permission="['admin','Classstandard:edit','Classstandard:del']"
|
||||
label="操作"
|
||||
width="150px"
|
||||
width="250px"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
style="display: inline"
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
:disabled-edit="scope.row.is_modify === '0'"
|
||||
:disabled-dle="scope.row.is_modify === '0'"
|
||||
msg="确定删除吗,如果存在下级节点则一并删除,此操作不能撤销!"
|
||||
/>
|
||||
<el-button slot="right" size="mini" type="text" icon="el-icon-circle-plus-outline" @click="crud.toAddAndData(addSibling(scope.row))">新增同级</el-button>
|
||||
<el-button slot="right" size="mini" type="text" icon="el-icon-circle-plus" @click="crud.toAddAndData(addChildren(scope.row))">新增子级</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -135,7 +139,7 @@ import udOperation from '@crud/UD.operation'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
const defaultForm = {
|
||||
let defaultForm = {
|
||||
class_id: null,
|
||||
base_data_type: null,
|
||||
path_code: null,
|
||||
@@ -180,14 +184,12 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
classes: [],
|
||||
classNames: [],
|
||||
permission: {},
|
||||
rules: {
|
||||
class_id: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
base_data_type: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
path_code: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
@@ -218,7 +220,15 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getClassNames() // 获取分类
|
||||
},
|
||||
methods: {
|
||||
getClassNames() {
|
||||
crudClassstandard.getClassName().then((res) => { // 获取分类名称,查询根据分类编码查找对应分支树
|
||||
this.classNames = res
|
||||
})
|
||||
},
|
||||
getClassDatas(tree, treeNode, resolve) {
|
||||
const params = { pid: tree.id }
|
||||
setTimeout(() => {
|
||||
@@ -318,6 +328,72 @@ export default {
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
},
|
||||
clearFrom() {
|
||||
defaultForm = {
|
||||
id: null,
|
||||
class_id: null,
|
||||
base_data_type: null,
|
||||
path_code: null,
|
||||
class_code: null,
|
||||
long_class_code: null,
|
||||
class_name: null,
|
||||
class_desc: null,
|
||||
parent_class_id: null,
|
||||
is_leaf: null,
|
||||
sub_count: null,
|
||||
is_modify: null,
|
||||
is_delete: null,
|
||||
class_level: null,
|
||||
ext_id: null,
|
||||
ext_parent_id: null,
|
||||
create_id: null,
|
||||
create_name: null,
|
||||
create_time: null,
|
||||
update_optid: null,
|
||||
update_optname: null,
|
||||
update_time: null,
|
||||
isTop: null
|
||||
}
|
||||
},
|
||||
addSibling(row) {
|
||||
this.clearFrom() // 将默认的表单数据清除
|
||||
defaultForm.id = row.id // 获取分类树的id - 懒加载依赖此id,不可为空
|
||||
defaultForm.class_id = row.class_id
|
||||
defaultForm.parent_class_id = row.parent_class_id // 同级为父类class_id
|
||||
defaultForm.isTop = row.isTop
|
||||
return defaultForm
|
||||
},
|
||||
addChildren(row) {
|
||||
this.clearFrom()
|
||||
defaultForm.id = row.id // 获取分类树的id
|
||||
defaultForm.class_id = row.parent_class_id
|
||||
defaultForm.parent_class_id = row.id // 子级为本身的class_id
|
||||
defaultForm.isTop = row.isTop
|
||||
return defaultForm
|
||||
},
|
||||
// 全部展开 参考:https://www.cnblogs.com/toughy/p/12667805.html
|
||||
ToExpandall() {
|
||||
const els = document.getElementsByClassName('el-table__expand-icon')
|
||||
if (this.crud.data.length !== 0 && els.length !== 0) {
|
||||
for (let j1 = 0; j1 < els.length; j1++) {
|
||||
els[j1].classList.add('dafult')
|
||||
}
|
||||
if (this.$el.getElementsByClassName('el-table__expand-icon--expanded')) {
|
||||
const open = this.$el.getElementsByClassName('el-table__expand-icon--expanded')
|
||||
for (let j = 0; j < open.length; j++) {
|
||||
open[j].classList.remove('dafult')
|
||||
}
|
||||
const dafult = this.$el.getElementsByClassName('dafult')
|
||||
for (let a = 0; a < dafult.length; a++) {
|
||||
debugger
|
||||
dafult[a].click()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
hand(value) {
|
||||
this.crud.toQuery()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user