master
lion 2 years ago
parent 9cbf549508
commit ba5a1ccc59

@ -0,0 +1,37 @@
import request from "@/utils/request";
export function index (params,isLoading=true) {
return request({
method: "get",
url: "/api/admin/category-rule/list",
params,
isLoading
})
}
export function store (data,isLoading=true) {
return request({
method: "post",
url: "/api/admin/category-rule/store",
data,
isLoading
})
}
export function save (data,isLoading=true) {
return request({
method: "post",
url: "/api/admin/category-rule/save",
data,
isLoading
})
}
export function destroy (data,isLoading=true) {
return request({
method: "post",
url: "/api/admin/category-rule/delete",
data,
isLoading
})
}

@ -11,7 +11,7 @@ export default {
render(h) { render(h) {
let dialog = new CreateDialog(this,[ let dialog = new CreateDialog(this,[
],{ ],{
width: "60%" width: "45%"
}) })
return dialog.render() return dialog.render()
}, },
@ -25,32 +25,25 @@ export default {
field: 'title', field: 'title',
edit_input: 'text', edit_input: 'text',
form_show: true, form_show: true,
_props: { // _props: {
type: "textarea", // type: "textarea",
autoSize: { // autoSize: {
minRows: 2 // minRows: 2
} // }
} // }
},
{
name: "表单",
field: "form_id",
edit_input: "radio",
form_show: true,
_params: []
},
{
name: '填报要求',
field: 'require',
edit_input: 'text',
form_show: true,
_props: {
type: "textarea",
autoSize: {
minRows: 4
}
}
}, },
// {
// name: '',
// field: 'require',
// edit_input: 'text',
// form_show: true,
// _props: {
// type: "textarea",
// autoSize: {
// minRows: 4
// }
// }
// },
{ {
name: '父栏目', name: '父栏目',
field: 'pid', field: 'pid',
@ -71,8 +64,10 @@ export default {
name: "年份", name: "年份",
field: "year", field: "year",
edit_input: "el-date-picker", edit_input: "el-date-picker",
// edit_input: "text",
form_show: true, form_show: true,
_props: { _props: {
// 'disabled':true
type: "year", type: "year",
"value-format": "yyyy" "value-format": "yyyy"
} }
@ -82,54 +77,57 @@ export default {
field: "type_id", field: "type_id",
edit_input: "radio", edit_input: "radio",
form_show: true, form_show: true,
_props:{
// 'disabled':true
},
_params: [] _params: []
}, },
{ // {
name: "考核周期", // name: "",
field: "measure_duration", // field: "measure_duration",
edit_input: "radio", // edit_input: "radio",
form_show: true, // form_show: true,
_params: [ // _params: [
{ // {
value: "monthly", // value: "monthly",
label: "月度" // label: ""
}, // },
{ // {
value: "quarterly", // value: "quarterly",
label: "季度" // label: ""
}, // },
{ // {
value: "yearly", // value: "yearly",
label: "年度" // label: ""
}, // },
] // ]
}, // },
{ // {
name: "考核方式", // name: "",
field: "measure_type", // field: "measure_type",
edit_input: "radio", // edit_input: "radio",
form_show: true, // form_show: true,
_params: [ // _params: [
{ // {
value: "check", // value: "check",
label: "仅回复是否执行" // label: ""
}, // },
{ // {
value: "reply", // value: "reply",
label: "需回复具体内容" // label: ""
} // }
] // ]
}, // },
{ // {
name: "考核数量", // name: "",
field: "measure_reply_quantity", // field: "measure_reply_quantity",
edit_input: "el-input-number", // edit_input: "el-input-number",
form_show: true, // form_show: true,
_props: { // _props: {
precision: 0, // precision: 0,
controls: false // controls: false
} // }
}, // },
{ {
name: '排序值', name: '排序值',
field: 'myindex', field: 'myindex',
@ -149,20 +147,20 @@ export default {
title: [ title: [
{ required: true,message: "请填写清单名称" } { required: true,message: "请填写清单名称" }
], ],
type_id: [ // type_id: [
{ required: true,message: "请选择清单类型" } // { required: true,message: "" }
], // ],
measure_reply_quantity: [ // measure_reply_quantity: [
{ // {
validator:(rule,value,cb) => { // validator:(rule,value,cb) => {
if (this.form['measure_type'] === 'reply') { // if (this.form['measure_type'] === 'reply') {
value > 0 ? cb() : cb(new Error('数量需大于0')) // value > 0 ? cb() : cb(new Error('0'))
} else { // } else {
cb() // cb()
} // }
} // }
} // }
] // ]
}, },
file: {}, file: {},
}; };

@ -0,0 +1,214 @@
<template>
<div>
<xy-dialog ref="dialog" :width="60" :is-show.sync="isShow" :type="'form'" :title="title" :form="form">
<template v-slot:table>
<xy-table
ref="xyTable"
:table-item="table"
:list="categoryRuleList"
:isPage='false'
>
<template v-slot:btns>
<el-table-column align='center' label="操作" width="120" header-align="center">
<template slot="header" slot-scope="scope">
<el-button
size="mini" @click="addRules">新增</el-button>
</template>
<template slot-scope="scope" style="display: flex;">
<Button style="margin-right:5px" size="small" type="primary" @click="submitRules(scope.row)"></Button>
<el-popover width="180"
:ref="`${scope.row.id}-${scope.$index}`"
trigger="hover">
<template>
<div>
<p style="padding-bottom: 10px;">确定要删除吗</p>
<div style="text-align: right;margin: 0;">
<el-button size="mini"
type="text"
@click="$refs[`${scope.row.id}-${scope.$index}`].doClose()"
>取消</el-button>
<el-button type="primary"
size="mini"
@click="delRules(scope.row,scope.$index)">确定</el-button>
</div>
</div>
</template>
<template #reference>
<Button
style="margin-right:6px;"
type="error"
size="small">
删除
</Button>
</template>
</el-popover>
</template>
</el-table-column>
</template>
</xy-table>
</template>
<template v-slot:footerContent>
<Button @click="isShow=false"></Button>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
Message
} from 'element-ui'
import { index,store,save,destroy} from "@/api/category/rule.js"
export default {
components: {
},
data() {
return {
isShow: false,
visible:false,
type: 'add',
title:'规则设置',
category_id:'',
id:'',
categoryRuleList:[],
form: {
table:''
},
table:[{
label: "开始日期",
prop: "start_at",
customFn: row => {
return(<el-date-picker v-model={row.start_at}
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="选择日期">
</el-date-picker>)
}
},{
label: "结束日期",
prop: "end_at",
customFn: row => {
return(<el-date-picker v-model={row.end_at}
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="选择日期">
</el-date-picker>)
}
},{
label: "填报数量",
prop: "quantity",
width:80,
customFn: row => {
return(<el-input type='text' v-model={row.quantity}></el-input>)
}
},{
label: "备注",
prop: "remark",
customFn: row => {
return(<el-input type='textarea' v-model={row.remark}></el-input>)
}
},{
label: "排序",
prop: "myindex",
width:80,
customFn: row => {
return(<el-input type='text' v-model={row.myindex}></el-input>)
}
}
],
rules: {
categoryRuleList: [{
required: true,
message: '请选择填报清单'
}]
}
}
},
created() {
},
methods: {
async getCategoryRule(){
const res = await index({
category_id:this.category_id
})
this.categoryRuleList = res
},
addRules(){
this.categoryRuleList.push({
category_id:this.category_id,
start_at:'',
end_at:'',
quantity:1,
remark:'',
myindex:0
})
},
delRules(row,index){
if(row.id){
destroy({
id:row.id
}).then(res=>{
this.$Message.success({
content: `删除成功`,
});
this.categoryRuleList.splice(index,1)
})
}else{
this.categoryRuleList.splice(index,1)
}
},
submitRules(row){
console.log("row",row)
if(this.isNull(row.start_at)||this.isNull(row.end_at)){
Message({
type:'warning',
message:'请填写全部信息'
})
return
}
if(row.id){
save(row).then(res => {
this.$Message.success({
content: `保存成功`,
});
this.getCategoryRule()
})
}else{
store(row).then(res => {
this.$Message.success({
content: `保存成功`,
});
this.getCategoryRule()
})
}
},
isNull(p){
return p == '' || p == undefined || p == null || p == 'undefined' || p == 'null';
},
},
watch: {
isShow(newVal) {
if(newVal){
this.getCategoryRule()
}else{
this.title='规则设置'
this.category_id=''
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .table{
flex-basis: 100%;
}
</style>

@ -1,259 +1,317 @@
<template> <template>
<div> <div>
<div>
<div ref="lxHeader">
<LxHeader style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<header-content :auths="auths_auth_mixin">
<template #search>
<div>
<div style="margin-bottom:15px">
<span style="margin-right:15px;display: inline-block;">年度 </span>
<el-radio-group v-model="select.year" @change="changeYear">
<el-radio style="margin-right:5px" v-for="item in yearList" border
:label="item">{{item}}</el-radio>
</el-radio-group>
</div>
<div>
<span style="margin-right:15px;display: inline-block;">类型 </span>
<el-radio-group @change="changeCategoryType" v-model="select.categoryType">
<el-radio style="margin-right:5px" v-for="item in categoryTypeList" border
:label="item.id">{{item.title}}</el-radio>
</el-radio-group>
</div>
<!-- <el-date-picker size="small" style="width: 110px;" placeholder="请选择日期" value-format="yyyy" v-model="select.year" type="year"></el-date-picker> -->
<!-- <Button
style="margin-left: 10px;"
type="primary"
@click="getList"
>查询</Button> -->
</div>
</template>
<!-- <template #create>
<Button type="primary" @click="$refs['create'].setType('add'),$refs['create'].show()"></Button>
</template>
<template #setting>
<Button type="primary" :ghost="isStartSelect" @click="isStartSelect = !isStartSelect">设置清单类型</Button>
</template> -->
</header-content>
</slot>
</LxHeader>
</div>
</div>
<div> <div>
<div ref="lxHeader"> <div style="margin-bottom:15px;">
<LxHeader <el-button @click="$refs['create'].setType('add'),
style="margin-bottom: 10px; border: 0px; margin-top: 15px" $refs['create'].setForm('type_id', select.categoryType),
> $refs['create'].setForm('year', select.year.toString()),
<div slot="content"></div> $refs['create'].show()" plain>新建{{select.year}}{{select.categoryTypeName}}清单</el-button>
<slot>
<header-content :auths="auths_auth_mixin">
<template #search>
<div style="display: flex">
<el-date-picker size="small" style="width: 110px;" placeholder="请选择日期" value-format="yyyy" v-model="select.year" type="year"></el-date-picker>
<Button
style="margin-left: 10px;"
type="primary"
@click="getList"
>查询</Button
>
</div>
</template>
<template #create>
<Button
type="primary"
@click="$refs['create'].setType('add'),$refs['create'].show()"
>新增</Button
>
</template>
<template #setting>
<Button type="primary" :ghost="isStartSelect" @click="isStartSelect = !isStartSelect">设置清单类型</Button>
</template>
</header-content>
</slot>
</LxHeader>
</div> </div>
</div> <xy-table ref="xyTable" :is-page="false" :list="list" res-prop="" :indent="20" :row-key="row => row._index"
:table-item="table" :auths="auths_auth_mixin" :req-opt="select" :destroy-action="destroy" @editor="row => {
<xy-table ref="xyTable" $refs['create'].setId(row.id);
:is-page="false" $refs['create'].setType('editor');
:list="list" $refs['create'].show();
res-prop="" }" @destroyed="getList">
:indent="20" <template #edit="{ row }">
:row-key="row => row._index" <Button v-if="row._type !== 'type'" size="small" type="primary" @click="$refs['create'].setId(row.id),
:table-item="table" $refs['create'].setType('editor'),
:auths="auths_auth_mixin" $refs['create'].show();">编辑</Button>
:req-opt="select" </template>
:destroy-action="destroy" <template #delete="{ row, column, $index }">
@editor="row => { <el-popover width="180" v-if="row._type !== 'type'" :ref="`${column.id}-${$index}`" trigger="hover">
$refs['create'].setId(row.id); <template>
$refs['create'].setType('editor'); <div>
$refs['create'].show(); <p style="padding-bottom: 10px;">确定要删除吗</p>
}" <div style="text-align: right;margin: 0;">
@destroyed="getList"> <el-button size="mini" type="text" @click="$refs[`${column.id}-${$index}`].doClose()"></el-button>
<template #edit="{ row }"> <el-button type="primary" size="mini"
<Button v-if="row._type !== 'type'" size="small" type="primary" @click="$refs['create'].setId(row.id), @click="$refs['xyTable'].deleteClick(row, 'delete')">确定</el-button>
$refs['create'].setType('editor'), </div>
$refs['create'].show();">编辑</Button>
</template>
<template #delete="{ row, column, $index }">
<el-popover width="180"
v-if="row._type !== 'type'"
:ref="`${column.id}-${$index}`"
trigger="hover">
<template>
<div>
<p style="padding-bottom: 10px;">确定要删除吗</p>
<div style="text-align: right;margin: 0;">
<el-button size="mini"
type="text"
@click="$refs[`${column.id}-${$index}`].doClose()">取消</el-button>
<el-button type="primary"
size="mini"
@click="$refs['xyTable'].deleteClick(row, 'delete')">确定</el-button>
</div> </div>
</div> </template>
</template> <template #reference>
<template #reference> <div style="margin-right: 6px;height: 100%;width: 100%;">
<div style="margin-right: 6px;height: 100%;width: 100%;"> <Button type="error" size="small" @click="$refs[`${column.id}-${$index}`].doShow()">
<Button 删除
type="error" </Button>
size="small" </div>
@click="$refs[`${column.id}-${$index}`].doShow()"> </template>
删除 </el-popover>
</Button> </template>
</div> <template #pid="{ row }">
</template> <Button size="small" type="primary" @click="createChild(row)"></Button>
</el-popover> </template>
</template> </xy-table>
<template #pid="{ row }"> </div>
<Button size="small" type="primary" @click="createChild(row)"></Button>
</template>
</xy-table> <create ref="create" :options="list" @refresh="getList"></create>
<create ref="create" :options="list" @refresh="getList"></create>
<categorySetting ref="categorySetting"></categorySetting> <categorySetting ref="categorySetting"></categorySetting>
</div> <createRules ref="createRules"></createRules>
</template> </div>
</template>
<script>
import { index,destroy } from "@/api/category" <script>
import { authMixin } from "@/mixin/authMixin"; import {
import headerContent from "@/components/LxHeader/XyContent.vue"; index,
import LxHeader from "@/components/LxHeader/index.vue"; destroy
import create from "./component/create.vue"; } from "@/api/category"
import categorySetting from "./component/categorySetting.vue"; import {
export default { index as categoryType
mixins: [authMixin], } from "@/api/categoryType"
components: { import {
categorySetting, authMixin
headerContent, } from "@/mixin/authMixin";
LxHeader, import headerContent from "@/components/LxHeader/XyContent.vue";
create import LxHeader from "@/components/LxHeader/index.vue";
}, import create from "./component/create.vue";
data() { import categorySetting from "./component/categorySetting.vue";
return { import createRules from "./component/createRules.vue";
provideOptions: [],
select: { export default {
year: this.$moment().format('YYYY') mixins: [authMixin],
}, components: {
isStartSelect: false, categorySetting,
list: [], headerContent,
table: [ LxHeader,
{ create,
type: "selection", createRules
width: 48, },
selectable:row => { data() {
return row._type === 'type' ? false : this.isStartSelect; return {
} provideOptions: [],
}, yearList: [],
{ categoryTypeList:[],
type: "", select: {
label: "", year: parseInt(this.$moment().format('YYYY')),
prop: "index", categoryType:'',
customFn:row => { categoryTypeName:''
return row._type === 'type' ? row._text : row._index; },
} isStartSelect: false,
}, list: [],
{ table: [
prop: "title", // {
label: "清单类型名称", // type: "selection",
align: "left", // width: 48,
customFn:row => { // selectable: row => {
return row._type === 'type' ? (<span><i style="padding: 0 8px;color: rgb(239, 216, 117);" class="el-icon-folder-opened"></i><span>{row.title}</span></span>) : ( // return row._type === 'type' ? false : this.isStartSelect;
<span><i style="padding: 0 8px;" class="el-icon-document"></i><span>{row.title}</span></span>) // }
} // },
}, {
{ type: "",
prop: "form", label: "",
label: "表单", prop: "index",
width: 120, customFn: row => {
customFn:row => { return row._type === 'type' ? row._text : row._index;
return row._type === 'type' ? "" : (<a href="javascript:;">填报表单</a>) }
} },
}, {
{ prop: "title",
prop: "records_count", label: '清单',
label: "填报数量", align: "left",
customFn:row => { customFn: row => {
if (!row.children?.length) { return row._type === 'type' ? ( <span> <i style = "padding: 0 8px;color: rgb(239, 216, 117);"
return (<span>{row.records_count}</span>) class = "el-icon-folder-opened"> </i><span>{row.title}</span> </span>) : ( <span> < i style = "padding: 0 8px;"
} class = "el-icon-document" > </i><span>{row.title}</span > </span>)
} }
}, },
{ {
prop: "myindex", prop: "records_count",
label: "排序" label: "预警规则",
} customFn: row => {
] return(<div>
} <el-button plain type='primary' size="mini"
}, on = {
methods: { {
index,destroy, ['click']: (e) => {
this.createRules(row)
toChineseNum(number) { }
const chineseNum = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"]; }
const chineseUnit = ["", "十", "百", "千", "万", "亿"]; }
let numStr = number.toString(); >规则设置</el-button>
let len = numStr.length; </div>)
let str = ""; }
for (let i = 0; i < len; i++) { },
str += chineseNum[parseInt(numStr[i])] + chineseUnit[len - 1 - i]; {
} prop: "myindex",
str = str.replace(/零[十百千]/g, "零"); label: "排序"
str = str.replace(/零+/g, "零"); }]
str = str.replace(/^零+/, ""); }
str = str.replace(/零+$/, ""); },
if (str[str.length - 1] === "零") { created() {
str = str.slice(0, -1); this.getList()
} this.yearList = this.getPastYears(5)
return str this.getCategoryType()
}, // this.select.year = this.$moment().format('YYYY')
},
formatList (data=[],pid) { methods: {
data.forEach((item,index) => { index,
if (item.hasOwnProperty('categories_tree')) { destroy,
item._id = item.id getCategoryType(){
delete item.id; categoryType({
item._disabled = true page:1,
item._type = 'type' page_size:9999
item.children = item.categories_tree }).then(res=>{
item._text = this.toChineseNum(index+1) this.categoryTypeList = res.data
} else { this.select.categoryType = res.data.length>0?res.data[0].id:''
item._type = 'doc' this.select.categoryTypeName = res.data.length>0?res.data[0].title:''
item._index = pid ? `${pid}-${index+1}` : (index+1)
}
if (item.children instanceof Array && item.children.length > 0) {
this.formatList(item.children,item._index ? item._index : false)
}
})
},
async getList () {
let res = await index();
this.formatList(res);
this.list = res;
},
createChild (row) {
if (row._type === 'type') {
this.$refs['create'].setForm('type_id',row._id);
this.$refs['create'].setForm('pid',0);
this.$refs['create'].setType('add');
this.$refs['create'].show();
} else {
this.$refs['create'].setForm('type_id',row.type_id);
this.$refs['create'].setForm('pid',row.id);
this.$refs['create'].setType('add');
this.$refs['create'].show();
}
}
},
computed: {},
watch: {
isStartSelect (newVal) {
const selections = this.$refs['xyTable'].getSelection()
if (!newVal && selections.length > 0) {
this.$refs['categorySetting'].setSelections(selections)
this.$refs['categorySetting'].show()
}
}
},
created() {
this.getList()
}
}
</script>
<style scoped lang="scss"> })
a { },
color: $primaryColor; changeYear(e){
text-decoration: none; if(e){
transition: all 0.2s; this.getList()
} }
},
changeCategoryType(e){
if(e){
this.categoryTypeList.map(item=>{
if(item.id===e){
this.select.categoryTypeName = item.title
}
})
}
a:hover { },
color: $primaryColor; toChineseNum(number) {
text-decoration: underline; const chineseNum = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
} const chineseUnit = ["", "十", "百", "千", "万", "亿"];
let numStr = number.toString();
let len = numStr.length;
let str = "";
for (let i = 0; i < len; i++) {
str += chineseNum[parseInt(numStr[i])] + chineseUnit[len - 1 - i];
}
str = str.replace(/零[十百千]/g, "零");
str = str.replace(/零+/g, "零");
str = str.replace(/^零+/, "");
str = str.replace(/零+$/, "");
if (str[str.length - 1] === "零") {
str = str.slice(0, -1);
}
return str
},
formatList(data = [], pid) {
data.forEach((item, index) => {
if (item.hasOwnProperty('categories_tree')) {
item._id = item.id
delete item.id;
item._disabled = true
item._type = 'type'
item.children = item.categories_tree
item._text = this.toChineseNum(index + 1)
} else {
item._type = 'doc'
item._index = pid ? `${pid}-${index+1}` : (index + 1)
// item._index = pid ? (index+1) : (index + 1)
}
if (item.children instanceof Array && item.children.length > 0) {
this.formatList(item.children, item._index ? item._index : false)
}
})
},
getPastYears(years) {
const currentYear = new Date().getFullYear();
return Array.from({
length: years
}, (_, index) => currentYear - index);
},
async getList() {
let res = await index({
year:this.select.year
});
this.formatList(res);
this.list = res;
},
createChild(row) {
if (row._type === 'type') {
this.$refs['create'].setForm('type_id', this.select.categoryType);
this.$refs['create'].setForm('pid', 0);
this.$refs['create'].setForm('year', this.select.year.toString());
this.$refs['create'].setType('add');
this.$refs['create'].show();
} else {
this.$refs['create'].setForm('type_id', this.select.categoryType);
this.$refs['create'].setForm('pid', row.id);
this.$refs['create'].setForm('year', this.select.year.toString());
this.$refs['create'].setType('add');
this.$refs['create'].show();
}
},
createRules(row){
console.log(row)
this.$refs['createRules'].category_id = row.id
this.$refs['createRules'].title = row.title;
this.$refs['createRules'].isShow = true;
}
},
computed: {},
watch: {
isStartSelect(newVal) {
const selections = this.$refs['xyTable'].getSelection()
if (!newVal && selections.length > 0) {
this.$refs['categorySetting'].setSelections(selections)
this.$refs['categorySetting'].show()
}
}
}
}
</script>
<style scoped lang="scss">
a {
color: $primaryColor;
text-decoration: none;
transition: all 0.2s;
}
a:hover {
color: $primaryColor;
text-decoration: underline;
}
</style> </style>

Loading…
Cancel
Save