清单页面全屏

master
lion 2 years ago
parent c5da4a58cf
commit 9da6d5e521

@ -0,0 +1,100 @@
<template>
<div>
<el-drawer
size="600px"
title="设置清单类型"
:visible.sync="drawer"
direction="rtl">
<div style="padding: 10px 20px;">
<el-descriptions direction="vertical" :column="2" :labelStyle="{ 'font-weight': 600 }">
<el-descriptions-item label="已选清单" :span="2">
<div v-for="(item, index) in selections">
<Tag closable color="primary" @on-close="selections.splice(index, 1)">
{{ item.title }}
</Tag>
</div>
</el-descriptions-item>
<el-descriptions-item label="人员选择" :span="2">
<Transfer
:data="persons"
:target-keys="selectedPersons"
filterable
:filter-method="filterMethod"
@on-change="arr => selectedPersons = arr"></Transfer>
</el-descriptions-item>
<el-descriptions-item label="开始填报月份">
<DatePicker type="month" v-model="startMonth" placeholder="请选择开始填报月份"></DatePicker>
</el-descriptions-item>
<el-descriptions-item label="结束填报月份">
<DatePicker type="month" v-model="endMonth" placeholder="请选择结束填报月份"></DatePicker>
</el-descriptions-item>
</el-descriptions>
<Button type="primary" shape="circle" style="width: 40%;margin-top: 20px;" @click="submit"></Button>
</div>
</el-drawer>
</div>
</template>
<script>
import { index, assignCategoryType } from "@/api/person";
export default {
data() {
return {
drawer: false,
selections: [],
persons: [],
selectedPersons: [],
startMonth: '',
endMonth: ''
}
},
methods: {
async getPersons () {
this.persons = (await index({ page: 1, page_size: 9999 },false)).data.map(i => ({
key: i.id,
label: i.name
}))
},
filterMethod (data, query) {
return data.label.indexOf(query) > -1;
},
setSelections (arr) {
if (arr instanceof Array) {
this.selections = arr
}
},
show () {
this.drawer = true;
},
hide () {
this.drawer = false;
},
submit () {
assignCategoryType({
person_id: this.selectedPersons.toString(),
category_id: this.selections.map(i => i.id).toString(),
start_year_month: this.$moment(this.startMonth).format("YYYY-MM"),
end_year_month: this.$moment(this.endMonth).format("YYYY-MM"),
}).then(res => {
this.hide()
})
}
},
computed: {},
created() {
this.getPersons()
}
}
</script>
<style scoped lang="scss">
::v-deep .ivu-tag {
height: auto;
line-height: 1.5;
padding: 4px 8px;
}
::v-deep .ivu-tag .ivu-icon-ios-close {
top: 0;
}
</style>

@ -0,0 +1,393 @@
<script>
import { index as typeIndex } from "@/api/categoryType";
import { index as formIndex } from "@/api/system/customForm";
import { save, show, store, index, destroy } from "@/api/category";
import { CreateDialog } from "@/utils/createDialog"
import { deepCopy } from "@/utils";
export default {
props: {
options: [Array,Object]
},
render(h) {
let dialog = new CreateDialog(this,[
],{
width: "45%"
})
return dialog.render()
},
data() {
return {
columns: 1,
row: {},
formInfo: [
{
name: '清单名称',
field: 'title',
edit_input: 'text',
form_show: true,
// _props: {
// type: "textarea",
// autoSize: {
// minRows: 2
// }
// }
},
// {
// name: '',
// field: 'require',
// edit_input: 'text',
// form_show: true,
// _props: {
// type: "textarea",
// autoSize: {
// minRows: 4
// }
// }
// },
{
name: '父栏目',
field: 'pid',
_default: 0,
edit_input: 'el-cascader',
form_show: true,
_props: {
disabled:true,
options: this.options,
props: { checkStrictly: true, value: "id", label: "title", disabled: "_disabled" },
},
_events: {
change: (e) => {
this.form.pid = e.at(-1);
}
}
},
{
name: "年份",
field: "year",
edit_input: "el-date-picker",
// edit_input: "text",
form_show: true,
_props: {
'disabled':true,
type: "year",
"value-format": "yyyy"
}
},
{
name: "清单类型",
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: 'myindex',
edit_input: 'el-input-number',
form_show: true,
_props: {
controls: false
}
}
],
id: "",
type: "add",
dialogVisible: false,
form: {},
originalForm: {},
rules: {
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()
// }
// }
// }
// ]
},
file: {},
};
},
methods: {
setRow (row) {
this.row = row
},
init() {
for (let key in this.form) {
if (this.formInfo.find(i => i.field === key)?._default) {
this.form[key] = this.formInfo.find(i => i.field === key)._default
}
else if (this.form[key] instanceof Array) {
this.form[key] = [];
} else {
this.form[key] = "";
}
}
this.$refs["elForm"].clearValidate();
},
setForm(key = [], value = []) {
if (key instanceof Array) {
key.forEach((key, index) => {
this.form[key] = value[index] ?? "";
});
}
if (typeof key === "string") {
this.form[key] = value;
}
if (!key) {
this.init();
}
},
show() {
this.dialogVisible = true;
},
hidden() {
this.dialogVisible = false;
},
setType(type = "add") {
let types = ["add", "editor", "show"];
if (types.includes(type)) {
this.type = type;
} else {
console.warn("Unknown type: " + type);
}
},
setId(id) {
if (typeof id == "number") {
this.id = id;
} else {
console.error("error typeof id: " + typeof id);
}
},
async getDetail() {
const res = await show({ id: this.id });
this.$integrateData(this.form, res);
this.formInfo.forEach((i) => {
if (i && (i.edit_input === "file" || i.edit_input === "files")) {
res[i._relations.link_with_name]
? (this.file[i.field] =
res[i._relations.link_with_name] instanceof Array
? res[i._relations.link_with_name].map((i) => {
return {
name: i?.name,
url: i?.url,
response: i,
};
})
: [
{
name: res[i._relations.link_with_name]?.name,
url: res[i._relations.link_with_name]?.url,
response: res[i._relations.link_with_name],
},
])
: (this.file[i.field] = []);
}
this.form = Object.assign({}, this.form);
this.originalForm = deepCopy(res);
});
},
submit() {
if (this.type === "add") {
if (this.form.hasOwnProperty("id")) {
delete this.form.id;
}
store(this.form).then(res => {
this.$Message.success({
content: `${this.type === "add" ? "新增" : "编辑"}成功`,
});
this.$emit("refresh");
this.hidden();
})
}
if (this.type === "editor") {
Object.defineProperty(this.form, "id", {
value: this.id,
enumerable: true,
configurable: true,
writable: true,
});
save(this.form).then(res => {
this.$Message.success({
content: `${this.type === "add" ? "新增" : "编辑"}成功`,
});
this.$emit("refresh");
this.hidden();
})
}
},
},
computed: {
title () {
if (this.type === 'add') return '新增'
if (this.type === 'editor') return '编辑'
if (this.type === 'show') return '查看'
}
},
watch: {
"form.year":{
handler:function (newVal) {
this.form.year = newVal.toString()
}
},
options(val){
this.$set(this.formInfo.find(i => i.field === 'pid')._props,'options',val)
},
formInfo: {
handler: function (newVal) {
this.form = {};
this.file = {};
newVal.forEach((i) => {
if (i.field) {
this.form[i.field] = (i._default || i._default === 0)? i._default : '';
if (
i.validation instanceof Array &&
i.validation.length > 0 &&
!!i.validation.find((i) => i === "required")
) {
}
if (i.edit_input === "files") {
this.form[i.field] = [];
}
if (i.edit_input === "files" || i.edit_input === "file") {
this.file[i.field] = [];
}
if (i.edit_input === "checkbox") {
this.form[i.field] = [];
}
if (i._relations) {
this.form[i._relations?.link_with_name] = [];
}
}
});
this.columns = newVal.length > 11 ? '2' : '1'
},
immediate: true,
},
dialogVisible(val) {
if (val) {
document.documentElement.style.setProperty(
"--column-num",
this.columns
);
if (this.type === "editor" || this.type === "show") {
// this.$nextTick(() => this.getDetail());
}
} else {
this.id = "";
this.type = "";
this.init();
this.$refs["elForm"].clearValidate();
delete this.form.id;
for (let key in this.file) {
this.file[key] = [];
}
}
},
},
created() {
this.formInfo.find(i => i.field === 'type_id')._params = []
this.formInfo.find(i => i.field === 'form_id')._params = []
// typeIndex({ page: 1,page_size: 999 }).then(res => {
// this.formInfo.find(i => i.field === 'type_id')._params = res.data
// })
// formIndex({ page: 1,page_size: 999 }).then(res => {
// this.formInfo.find(i => i.field === 'form_id')._params = res.data
// })
}
};
</script>
<style>
:root {
--column-num: 2;
}
</style>
<style scoped lang="scss">
.uploaded-a {
color: red;
text-decoration: none;
transition: all 0.2s;
}
.uploaded-a:hover {
color: red;
text-decoration: underline;
}
.form-body {
display: grid;
grid-gap: 10px;
grid-template-columns: repeat(var(--column-num), 1fr);
}
::v-deep .el-input-number.is-without-controls .el-input__inner {
text-align: left;
}
</style>

@ -0,0 +1,221 @@
<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 v-if="!scope.row.isEdit" style="margin-right:5px" size="small" type="primary" @click="submitRules(scope.row)"></Button>
<Button v-else style="margin-right:5px" size="small" type="primary" @click="scope.row.isEdit=false"></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,$emit('refresh')"></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"
disabled={row.isEdit}
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"
disabled={row.isEdit}
value-format="yyyy-MM-dd"
placeholder="选择日期">
</el-date-picker>)
}
},{
label: "填报数量",
prop: "quantity",
width:80,
customFn: row => {
return(<el-input type='text' disabled={row.isEdit} v-model={row.quantity}></el-input>)
}
},{
label: "备注",
prop: "remark",
customFn: row => {
return(<el-input type='textarea' disabled={row.isEdit} v-model={row.remark}></el-input>)
}
},{
label: "排序",
prop: "myindex",
width:80,
customFn: row => {
return(<el-input type='text' disabled={row.isEdit} v-model={row.myindex}></el-input>)
}
}
],
rules: {
categoryRuleList: [{
required: true,
message: '请选择填报清单'
}]
}
}
},
created() {
},
methods: {
async getCategoryRule(){
const res = await index({
category_id:this.category_id
})
res.map(item=>{
item.isEdit = true
})
this.categoryRuleList = res
console.log("this.categoryRuleList",this.categoryRuleList)
},
addRules(){
this.categoryRuleList.push({
category_id:this.category_id,
isEdit:false,
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>

@ -89,7 +89,7 @@
<create ref="create" :options="list" @refresh="getList"></create>
<categorySetting ref="categorySetting"></categorySetting>
<!-- <categorySetting ref="categorySetting"></categorySetting> -->
<createRules ref="createRules" @refresh="getList"></createRules>
</div>
</template>
@ -106,14 +106,14 @@
} from "@/mixin/authMixin";
import headerContent from "@/components/LxHeader/XyContent.vue";
import LxHeader from "@/components/LxHeader/index.vue";
import create from "@/views/category/component/create.vue";
import categorySetting from "@/views/category/component/categorySetting.vue";
import createRules from "@/views/category/component/createRules.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,
// categorySetting,
headerContent,
LxHeader,
create,
@ -308,13 +308,13 @@
},
computed: {},
watch: {
isStartSelect(newVal) {
const selections = this.$refs['xyTable'].getSelection()
if (!newVal && selections.length > 0) {
this.$refs['categorySetting'].setSelections(selections)
this.$refs['categorySetting'].show()
}
}
// isStartSelect(newVal) {
// const selections = this.$refs['xyTable'].getSelection()
// if (!newVal && selections.length > 0) {
// this.$refs['categorySetting'].setSelections(selections)
// this.$refs['categorySetting'].show()
// }
// }
}
}
</script>

Loading…
Cancel
Save