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) {
let dialog = new CreateDialog(this,[
],{
width: "60%"
width: "45%"
})
return dialog.render()
},
@ -25,32 +25,25 @@ export default {
field: 'title',
edit_input: 'text',
form_show: true,
_props: {
type: "textarea",
autoSize: {
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
}
}
// _props: {
// type: "textarea",
// autoSize: {
// minRows: 2
// }
// }
},
// {
// name: '',
// field: 'require',
// edit_input: 'text',
// form_show: true,
// _props: {
// type: "textarea",
// autoSize: {
// minRows: 4
// }
// }
// },
{
name: '父栏目',
field: 'pid',
@ -71,8 +64,10 @@ export default {
name: "年份",
field: "year",
edit_input: "el-date-picker",
// edit_input: "text",
form_show: true,
_props: {
// 'disabled':true
type: "year",
"value-format": "yyyy"
}
@ -82,54 +77,57 @@ export default {
field: "type_id",
edit_input: "radio",
form_show: true,
_props:{
// 'disabled':true
},
_params: []
},
{
name: "考核周期",
field: "measure_duration",
edit_input: "radio",
form_show: true,
_params: [
{
value: "monthly",
label: "月度"
},
{
value: "quarterly",
label: "季度"
},
{
value: "yearly",
label: "年度"
},
]
},
{
name: "考核方式",
field: "measure_type",
edit_input: "radio",
form_show: true,
_params: [
{
value: "check",
label: "仅回复是否执行"
},
{
value: "reply",
label: "需回复具体内容"
}
]
},
{
name: "考核数量",
field: "measure_reply_quantity",
edit_input: "el-input-number",
form_show: true,
_props: {
precision: 0,
controls: false
}
},
// {
// name: "",
// field: "measure_duration",
// edit_input: "radio",
// form_show: true,
// _params: [
// {
// value: "monthly",
// label: ""
// },
// {
// value: "quarterly",
// label: ""
// },
// {
// value: "yearly",
// label: ""
// },
// ]
// },
// {
// name: "",
// field: "measure_type",
// edit_input: "radio",
// form_show: true,
// _params: [
// {
// value: "check",
// label: ""
// },
// {
// value: "reply",
// label: ""
// }
// ]
// },
// {
// name: "",
// field: "measure_reply_quantity",
// edit_input: "el-input-number",
// form_show: true,
// _props: {
// precision: 0,
// controls: false
// }
// },
{
name: '排序值',
field: 'myindex',
@ -149,20 +147,20 @@ export default {
title: [
{ required: true,message: "请填写清单名称" }
],
type_id: [
{ required: true,message: "请选择清单类型" }
],
measure_reply_quantity: [
{
validator:(rule,value,cb) => {
if (this.form['measure_type'] === 'reply') {
value > 0 ? cb() : cb(new Error('数量需大于0'))
} else {
cb()
}
}
}
]
// type_id: [
// { required: true,message: "" }
// ],
// measure_reply_quantity: [
// {
// validator:(rule,value,cb) => {
// if (this.form['measure_type'] === 'reply') {
// value > 0 ? cb() : cb(new Error('0'))
// } else {
// cb()
// }
// }
// }
// ]
},
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>
<div>
<template>
<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 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 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 style="margin-bottom:15px;">
<el-button @click="$refs['create'].setType('add'),
$refs['create'].setForm('type_id', select.categoryType),
$refs['create'].setForm('year', select.year.toString()),
$refs['create'].show()" plain>新建{{select.year}}{{select.categoryTypeName}}清单</el-button>
</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 => {
$refs['create'].setId(row.id);
$refs['create'].setType('editor');
$refs['create'].show();
}"
@destroyed="getList">
<template #edit="{ row }">
<Button v-if="row._type !== 'type'" size="small" type="primary" @click="$refs['create'].setId(row.id),
$refs['create'].setType('editor'),
$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>
<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 => {
$refs['create'].setId(row.id);
$refs['create'].setType('editor');
$refs['create'].show();
}" @destroyed="getList">
<template #edit="{ row }">
<Button v-if="row._type !== 'type'" size="small" type="primary" @click="$refs['create'].setId(row.id),
$refs['create'].setType('editor'),
$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 #reference>
<div style="margin-right: 6px;height: 100%;width: 100%;">
<Button
type="error"
size="small"
@click="$refs[`${column.id}-${$index}`].doShow()">
删除
</Button>
</div>
</template>
</el-popover>
</template>
<template #pid="{ row }">
<Button size="small" type="primary" @click="createChild(row)"></Button>
</template>
</xy-table>
<create ref="create" :options="list" @refresh="getList"></create>
</template>
<template #reference>
<div style="margin-right: 6px;height: 100%;width: 100%;">
<Button type="error" size="small" @click="$refs[`${column.id}-${$index}`].doShow()">
删除
</Button>
</div>
</template>
</el-popover>
</template>
<template #pid="{ row }">
<Button size="small" type="primary" @click="createChild(row)"></Button>
</template>
</xy-table>
</div>
<create ref="create" :options="list" @refresh="getList"></create>
<categorySetting ref="categorySetting"></categorySetting>
</div>
</template>
<script>
import { index,destroy } from "@/api/category"
import { authMixin } from "@/mixin/authMixin";
import headerContent from "@/components/LxHeader/XyContent.vue";
import LxHeader from "@/components/LxHeader/index.vue";
import create from "./component/create.vue";
import categorySetting from "./component/categorySetting.vue";
export default {
mixins: [authMixin],
components: {
categorySetting,
headerContent,
LxHeader,
create
},
data() {
return {
provideOptions: [],
select: {
year: this.$moment().format('YYYY')
},
isStartSelect: false,
list: [],
table: [
{
type: "selection",
width: 48,
selectable:row => {
return row._type === 'type' ? false : this.isStartSelect;
}
},
{
type: "",
label: "",
prop: "index",
customFn:row => {
return row._type === 'type' ? row._text : row._index;
}
},
{
prop: "title",
label: "清单类型名称",
align: "left",
customFn: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>) : (
<span><i style="padding: 0 8px;" class="el-icon-document"></i><span>{row.title}</span></span>)
}
},
{
prop: "form",
label: "表单",
width: 120,
customFn:row => {
return row._type === 'type' ? "" : (<a href="javascript:;">填报表单</a>)
}
},
{
prop: "records_count",
label: "填报数量",
customFn:row => {
if (!row.children?.length) {
return (<span>{row.records_count}</span>)
}
}
},
{
prop: "myindex",
label: "排序"
}
]
}
},
methods: {
index,destroy,
toChineseNum(number) {
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)
}
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>
<createRules ref="createRules"></createRules>
</div>
</template>
<script>
import {
index,
destroy
} from "@/api/category"
import {
index as categoryType
} from "@/api/categoryType"
import {
authMixin
} from "@/mixin/authMixin";
import headerContent from "@/components/LxHeader/XyContent.vue";
import LxHeader from "@/components/LxHeader/index.vue";
import create from "./component/create.vue";
import categorySetting from "./component/categorySetting.vue";
import createRules from "./component/createRules.vue";
export default {
mixins: [authMixin],
components: {
categorySetting,
headerContent,
LxHeader,
create,
createRules
},
data() {
return {
provideOptions: [],
yearList: [],
categoryTypeList:[],
select: {
year: parseInt(this.$moment().format('YYYY')),
categoryType:'',
categoryTypeName:''
},
isStartSelect: false,
list: [],
table: [
// {
// type: "selection",
// width: 48,
// selectable: row => {
// return row._type === 'type' ? false : this.isStartSelect;
// }
// },
{
type: "",
label: "",
prop: "index",
customFn: row => {
return row._type === 'type' ? row._text : row._index;
}
},
{
prop: "title",
label: '清单',
align: "left",
customFn: 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>) : ( <span> < i style = "padding: 0 8px;"
class = "el-icon-document" > </i><span>{row.title}</span > </span>)
}
},
{
prop: "records_count",
label: "预警规则",
customFn: row => {
return(<div>
<el-button plain type='primary' size="mini"
on = {
{
['click']: (e) => {
this.createRules(row)
}
}
}
>规则设置</el-button>
</div>)
}
},
{
prop: "myindex",
label: "排序"
}]
}
},
created() {
this.getList()
this.yearList = this.getPastYears(5)
this.getCategoryType()
// this.select.year = this.$moment().format('YYYY')
},
methods: {
index,
destroy,
getCategoryType(){
categoryType({
page:1,
page_size:9999
}).then(res=>{
this.categoryTypeList = res.data
this.select.categoryType = res.data.length>0?res.data[0].id:''
this.select.categoryTypeName = res.data.length>0?res.data[0].title:''
<style scoped lang="scss">
a {
color: $primaryColor;
text-decoration: none;
transition: all 0.2s;
}
})
},
changeYear(e){
if(e){
this.getList()
}
},
changeCategoryType(e){
if(e){
this.categoryTypeList.map(item=>{
if(item.id===e){
this.select.categoryTypeName = item.title
}
})
}
a:hover {
color: $primaryColor;
text-decoration: underline;
}
},
toChineseNum(number) {
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>

Loading…
Cancel
Save