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: "表单", // name: '',
field: "form_id", // field: 'require',
edit_input: "radio", // edit_input: 'text',
form_show: true, // form_show: true,
_params: [] // _props: {
}, // type: "textarea",
{ // autoSize: {
name: '填报要求', // minRows: 4
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,
_params: [] _props:{
}, // 'disabled':true
{
name: "考核周期",
field: "measure_duration",
edit_input: "radio",
form_show: true,
_params: [
{
value: "monthly",
label: "月度"
},
{
value: "quarterly",
label: "季度"
}, },
{ _params: []
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: '排序值', 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>

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

Loading…
Cancel
Save