master
lion 2 years ago
parent ba5a1ccc59
commit b3d7cd177b

@ -44,3 +44,21 @@ export function destroy (data,isLoading=true) {
isLoading
})
}
export function categoryYears(params,isLoading=true) {
return request({
method: "get",
url: "/api/admin/get-years",
params,
isLoading
})
}
export function categoryTypes(params,isLoading=true) {
return request({
method: "get",
url: "/api/admin/get-category-types",
params,
isLoading
})
}

@ -15,7 +15,8 @@
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>
<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}`"
@ -50,7 +51,7 @@
</template>
<template v-slot:footerContent>
<Button @click="isShow=false"></Button>
<Button @click="isShow=false,$emit('refresh')"></Button>
</template>
</xy-dialog>
@ -83,6 +84,7 @@ import { index,store,save,destroy} from "@/api/category/rule.js"
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="选择日期">
@ -95,6 +97,7 @@ import { index,store,save,destroy} from "@/api/category/rule.js"
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>)
@ -104,20 +107,20 @@ import { index,store,save,destroy} from "@/api/category/rule.js"
prop: "quantity",
width:80,
customFn: row => {
return(<el-input type='text' v-model={row.quantity}></el-input>)
return(<el-input type='text' disabled={row.isEdit} v-model={row.quantity}></el-input>)
}
},{
label: "备注",
prop: "remark",
customFn: row => {
return(<el-input type='textarea' v-model={row.remark}></el-input>)
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' v-model={row.myindex}></el-input>)
return(<el-input type='text' disabled={row.isEdit} v-model={row.myindex}></el-input>)
}
}
],
@ -136,12 +139,16 @@ import { index,store,save,destroy} from "@/api/category/rule.js"
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,

@ -17,7 +17,7 @@
</div>
<div>
<span style="margin-right:15px;display: inline-block;">类型 </span>
<el-radio-group @change="changeCategoryType" v-model="select.categoryType">
<el-radio-group @change="changeCategoryType" v-model="select.category_type_id">
<el-radio style="margin-right:5px" v-for="item in categoryTypeList" border
:label="item.id">{{item.title}}</el-radio>
</el-radio-group>
@ -44,8 +44,8 @@
<div>
<div style="margin-bottom:15px;">
<el-button @click="$refs['create'].setType('add'),
$refs['create'].setForm('type_id', select.categoryType),
<el-button v-if="select.category_type_id" @click="$refs['create'].setType('add'),
$refs['create'].setForm('type_id', select.category_type_id),
$refs['create'].setForm('year', select.year.toString()),
$refs['create'].show()" plain>新建{{select.year}}{{select.categoryTypeName}}清单</el-button>
</div>
@ -55,53 +55,67 @@
$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>
</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>
<template v-slot:btns>
<el-table-column align='center' fixed="right" label="操作" width="220" header-align="center">
<template slot="header" slot-scope="scope">
<el-button
size="mini" @click="">整体克隆</el-button>
</template>
<template slot-scope="scope">
<div style="display: flex;">
<Button v-if="scope.row._type !== 'type'" size="small" type="primary" @click="$refs['create'].setId(scope.row.id),
$refs['create'].setType('editor'),
$refs['create'].show();">编辑</Button>
<el-popover width="180" v-if="scope.row._type !== 'type'" :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="$refs['xyTable'].deleteClick(scope.row, 'delete')">确定</el-button>
</div>
</div>
</template>
<template #reference>
<div style="margin-right: 6px;height: 100%;width: 100%;">
<Button type="error" size="small" @click="$refs[`${scope.row.id}-${scope.$index}`].doShow()">
删除
</Button>
</div>
</template>
</el-popover>
<Button size="small" type="primary" @click="createChild(scope.row)"></Button>
</div>
</template>
</el-table-column>
</template>
</xy-table>
</div>
<create ref="create" :options="list" @refresh="getList"></create>
<categorySetting ref="categorySetting"></categorySetting>
<createRules ref="createRules"></createRules>
<createRules ref="createRules" @refresh="getList"></createRules>
</div>
</template>
<script>
import {
index,
destroy
} from "@/api/category"
import {
index as categoryType
} from "@/api/categoryType"
destroy,
categoryYears,
categoryTypes
} from "@/api/category"
import {
authMixin
} from "@/mixin/authMixin";
@ -126,8 +140,8 @@
yearList: [],
categoryTypeList:[],
select: {
year: parseInt(this.$moment().format('YYYY')),
categoryType:'',
year: '',
category_type_id:'',
categoryTypeName:''
},
isStartSelect: false,
@ -172,6 +186,11 @@
}
}
>规则设置</el-button>
<div>{
row.rules.map(item=>{
return(<div>{item.start_at}~{item.end_at}不少于{item.quantity}</div>)
})
}</div>
</div>)
}
},
@ -181,9 +200,10 @@
}]
}
},
created() {
created() {
this.getPastYears()
this.getList()
this.yearList = this.getPastYears(5)
// this.yearList = this.getPastYears(5)
this.getCategoryType()
// this.select.year = this.$moment().format('YYYY')
},
@ -191,13 +211,10 @@
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:''
categoryTypes().then(res=>{
this.categoryTypeList = res
// this.select.categoryType = res.data.length>0?res.data[0].id:''
// this.select.categoryTypeName = res.data.length>0?res.data[0].title:''
})
},
@ -213,6 +230,7 @@
this.select.categoryTypeName = item.title
}
})
this.getList()
}
},
@ -254,29 +272,34 @@
}
})
},
getPastYears(years) {
const currentYear = new Date().getFullYear();
return Array.from({
length: years
}, (_, index) => currentYear - index);
getPastYears(years) {
categoryYears().then(res=>{
this.yearList = res.years
this.select.year = res.selected_year
})
},
async getList() {
let res = await index({
year:this.select.year
year:this.select.year,
category_type_id:this.select.category_type_id
});
this.formatList(res);
this.list = res;
},
createChild(row) {
createChild(row) {
let category_type_id = this.select.category_type_id
if(row.type_id){
category_type_id = row.type_id
}
if (row._type === 'type') {
this.$refs['create'].setForm('type_id', this.select.categoryType);
this.$refs['create'].setForm('type_id', category_type_id);
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('type_id', category_type_id);
this.$refs['create'].setForm('pid', row.id);
this.$refs['create'].setForm('year', this.select.year.toString());
this.$refs['create'].setType('add');
@ -285,7 +308,12 @@
},
createRules(row){
console.log(row)
this.$refs['createRules'].category_id = row.id
if(row._type==='type'){
this.$refs['createRules'].category_id = row._id
}else{
this.$refs['createRules'].category_id = row.id
}
this.$refs['createRules'].title = row.title;
this.$refs['createRules'].isShow = true;
}

Loading…
Cancel
Save