fix some error and warning
This commit is contained in:
parent
fe5c9fd1a9
commit
8db8241295
@ -6,7 +6,7 @@ export interface IRewardData {
|
||||
rank?: number,
|
||||
rankEnd?: number,
|
||||
coupon?: string,
|
||||
count: number
|
||||
count?: number
|
||||
}
|
||||
|
||||
export interface IActivityData {
|
||||
@ -22,7 +22,7 @@ export interface IActivityData {
|
||||
beginTime: number[]
|
||||
prepareTime: number
|
||||
active: number,
|
||||
beginDays?: number[],
|
||||
beginDays: number[],
|
||||
beginDay?: number,
|
||||
endDay?: number,
|
||||
rewardInfo: IRewardData[]
|
||||
@ -33,6 +33,7 @@ export const defaultRewardData: IRewardData = {
|
||||
}
|
||||
|
||||
export const defaultActivityData: IActivityData = {
|
||||
beginDays: [],
|
||||
active: 0,
|
||||
beginTime: [],
|
||||
monthDays: [],
|
||||
|
@ -18,6 +18,7 @@ export interface IAreaData {
|
||||
adcode: string
|
||||
type: number
|
||||
location: ILocation
|
||||
showStr?: string
|
||||
}
|
||||
|
||||
export async function queryArea(str: string, region: string) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export const getPermissions = (params: any) =>
|
||||
export const getPermissions = (params?: any) =>
|
||||
request({
|
||||
url: '/permissions',
|
||||
method: 'get',
|
||||
|
@ -4,7 +4,8 @@ import { IShopData } from './types'
|
||||
export const defaultShopData: IShopData = {
|
||||
name: '',
|
||||
address: '',
|
||||
logo: ''
|
||||
logo: '',
|
||||
qtypes: []
|
||||
}
|
||||
|
||||
export const getShops = (params: any) =>
|
||||
|
3
src/api/types.d.ts
vendored
3
src/api/types.d.ts
vendored
@ -26,5 +26,6 @@ export interface IShopData {
|
||||
lat?: number
|
||||
showName?: string
|
||||
extData?: string
|
||||
category?: string
|
||||
category?: string,
|
||||
qtypes: string[]
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
|
||||
<el-form
|
||||
ref="postForm"
|
||||
:model="postForm"
|
||||
@ -216,7 +215,7 @@
|
||||
show-checkbox
|
||||
accordion
|
||||
node-key="id"
|
||||
ref="tree"
|
||||
ref="typeTree"
|
||||
highlight-current
|
||||
:default-checked-keys="typeSelected"
|
||||
:props="defaultProps">
|
||||
@ -367,11 +366,11 @@ import MaterialInput from '@/components/MaterialInput/index.vue'
|
||||
import Sticky from '@/components/Sticky/index.vue'
|
||||
import UploadImage from '@/components/UploadImage/index.vue'
|
||||
import RegionPicker from '@/components/RegionPicker/index.vue'
|
||||
import { Form } from 'element-ui'
|
||||
import Tinymce from '@/components/Tinymce/index.vue'
|
||||
import { getShops } from '@/api/shop'
|
||||
import {
|
||||
defaultActivityData, defaultRewardData,
|
||||
defaultActivityData,
|
||||
defaultRewardData,
|
||||
getActivity,
|
||||
IRewardData,
|
||||
saveActivity
|
||||
@ -379,8 +378,9 @@ import {
|
||||
import { sec2TimeStr, timeStr2Sec } from '@/utils'
|
||||
import { getAllCategory } from '@/api/question'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { getCoupons } from '@/api/coupon'
|
||||
import { deleteAdmin } from '@/api/admins'
|
||||
import { getCoupons, ICouponData } from '@/api/coupon'
|
||||
import { IShopData } from '@/api/types'
|
||||
import { ElTree } from 'element-ui/types/tree'
|
||||
|
||||
@Component({
|
||||
name: 'ActivityEditor',
|
||||
@ -393,7 +393,6 @@ import { deleteAdmin } from '@/api/admins'
|
||||
}
|
||||
})
|
||||
export default class extends Vue {
|
||||
|
||||
private validateRequire = (rule: any, value: string, callback: Function) => {
|
||||
if (value === '') {
|
||||
if (rule.field === 'imageURL') {
|
||||
@ -412,8 +411,9 @@ export default class extends Vue {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
private activeName = 'first'
|
||||
private monthDays = []
|
||||
private monthDays: {id: number, label: string}[] = []
|
||||
private repeatTypes = [
|
||||
{ id: 0, label: '指定日期' },
|
||||
{ id: 1, label: '每日' },
|
||||
@ -421,6 +421,7 @@ export default class extends Vue {
|
||||
{ id: 3, label: '每月' },
|
||||
{ id: 9, label: '随时(一般测试用)' }
|
||||
]
|
||||
|
||||
private weekDays = [
|
||||
{ id: 0, label: '周日' },
|
||||
{ id: 1, label: '周一' },
|
||||
@ -430,16 +431,17 @@ export default class extends Vue {
|
||||
{ id: 5, label: '周五' },
|
||||
{ id: 6, label: '周六' }
|
||||
]
|
||||
|
||||
private dataRange: Date[] = []
|
||||
private selectDate: Date[] = []
|
||||
private times = []
|
||||
private times: string[] = []
|
||||
private selectTime: string[] = []
|
||||
|
||||
private postForm = Object.assign({}, defaultActivityData)
|
||||
private loading = false
|
||||
private allDepts = []
|
||||
private allDepts: IShopData[] = []
|
||||
private typeOptions: {id: string, label: string, children?: any[]}[] = []
|
||||
private typeSelected = []
|
||||
private typeSelected: string[] = []
|
||||
private defaultProps = {
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
@ -451,22 +453,26 @@ export default class extends Vue {
|
||||
|
||||
private tempTagView?: ITagView
|
||||
|
||||
|
||||
private dialogType = 'new'
|
||||
private record: IRewardData = {}
|
||||
private dialogVisible = false
|
||||
private modalRules = {
|
||||
rank: [{ required: true, message: '请输入排名', trigger: 'blur' },
|
||||
],
|
||||
rank: [{ required: true, message: '请输入排名', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
private coupons = []
|
||||
|
||||
private coupons: ICouponData[] = []
|
||||
|
||||
$refs!: {
|
||||
modalForm: HTMLFormElement
|
||||
postForm: HTMLFormElement
|
||||
typeTree: ElTree<any, any>
|
||||
}
|
||||
|
||||
get lang() {
|
||||
return AppModule.language
|
||||
}
|
||||
|
||||
|
||||
async created() {
|
||||
this.initTimes()
|
||||
const id = this.$route.params?.id
|
||||
@ -478,12 +484,6 @@ export default class extends Vue {
|
||||
this.tempTagView = Object.assign({}, this.$route)
|
||||
}
|
||||
|
||||
deactivated() {
|
||||
}
|
||||
|
||||
activated() {
|
||||
}
|
||||
|
||||
private async fetchData(id: string) {
|
||||
try {
|
||||
const { data } = await getActivity(id, { /* Your params here */ })
|
||||
@ -491,13 +491,13 @@ export default class extends Vue {
|
||||
this.postForm = data
|
||||
this.selectTime = []
|
||||
if (data.beginTime) {
|
||||
for (let str of data.beginTime) {
|
||||
for (const str of data.beginTime) {
|
||||
this.selectTime.push(sec2TimeStr(str, false))
|
||||
}
|
||||
}
|
||||
this.selectDate = []
|
||||
if (data.beginDays) {
|
||||
for (let sub of data.beginDays) {
|
||||
for (const sub of data.beginDays) {
|
||||
this.selectDate.push(new Date(sub))
|
||||
}
|
||||
}
|
||||
@ -520,33 +520,32 @@ export default class extends Vue {
|
||||
private setTagsViewTitle(title: string) {
|
||||
const tagView = this.tempTagView
|
||||
if (tagView) {
|
||||
tagView.title = `${ title }-${ this.postForm._id }`
|
||||
tagView.title = `${title}-${this.postForm._id}`
|
||||
TagsViewModule.updateVisitedView(tagView)
|
||||
}
|
||||
}
|
||||
|
||||
private setPageTitle(title: string) {
|
||||
document.title = `${ title } - ${ this.postForm._id }`
|
||||
document.title = `${title} - ${this.postForm._id}`
|
||||
}
|
||||
|
||||
private async submitForm() {
|
||||
const form = <Form>this.$refs.postForm
|
||||
try {
|
||||
await form.validate()
|
||||
let times = []
|
||||
for (let str of this.selectTime) {
|
||||
await this.$refs.postForm.validate()
|
||||
const times = []
|
||||
for (const str of this.selectTime) {
|
||||
times.push(timeStr2Sec(str))
|
||||
}
|
||||
this.postForm.beginTime = times
|
||||
this.postForm.beginDays.length = 0
|
||||
for (let d of this.selectDate) {
|
||||
for (const d of this.selectDate) {
|
||||
this.postForm.beginDays.push(d.getTime())
|
||||
}
|
||||
if (this.dataRange.length > 1) {
|
||||
this.postForm.beginDay = this.dataRange[0].getTime()
|
||||
this.postForm.endDay = this.dataRange[1].getTime()
|
||||
}
|
||||
this.postForm.qtypes = this.$refs.tree.getCheckedKeys()
|
||||
this.postForm.qtypes = this.$refs.typeTree.getCheckedKeys()
|
||||
this.loading = true
|
||||
const { data } = await saveActivity(this.postForm)
|
||||
this.postForm = data
|
||||
@ -575,7 +574,6 @@ export default class extends Vue {
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async getRemoteDeptList() {
|
||||
@ -584,21 +582,21 @@ export default class extends Vue {
|
||||
this.allDepts = data.records
|
||||
}
|
||||
|
||||
private dataChange(val: any) {
|
||||
private dataChange(_: any) {
|
||||
console.log(this.selectDate)
|
||||
}
|
||||
|
||||
private initTimes() {
|
||||
for (let i = 0; i < 24; i++) {
|
||||
for (let j = 0; j < 4; j++) {
|
||||
let secs = i * 3600 + j * 15 * 60
|
||||
let label = sec2TimeStr(secs, false)
|
||||
const secs = i * 3600 + j * 15 * 60
|
||||
const label = sec2TimeStr(secs, false)
|
||||
this.times.push(label)
|
||||
}
|
||||
}
|
||||
this.monthDays.push({ id: 0, label: '全选' })
|
||||
for (let i = 1; i < 32; i++) {
|
||||
this.monthDays.push({ id: i, label: i })
|
||||
this.monthDays.push({ id: i, label: i + '' })
|
||||
}
|
||||
}
|
||||
|
||||
@ -612,7 +610,6 @@ export default class extends Vue {
|
||||
this.selectTime.splice(this.selectTime.length - 1, 1, lastVal)
|
||||
console.log(this.selectTime)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private monthDaysChange(days: number[]) {
|
||||
@ -636,8 +633,8 @@ export default class extends Vue {
|
||||
}
|
||||
if (this.postForm.shop) {
|
||||
let currentShop
|
||||
for (let p of this.allDepts) {
|
||||
if (p._id == this.postForm.shop) {
|
||||
for (const p of this.allDepts) {
|
||||
if (p._id === this.postForm.shop) {
|
||||
currentShop = p
|
||||
break
|
||||
}
|
||||
@ -647,7 +644,7 @@ export default class extends Vue {
|
||||
} else {
|
||||
this.typeSelected = []
|
||||
}
|
||||
this.$refs.tree.setCheckedKeys(this.typeSelected)
|
||||
this.$refs.typeTree.setCheckedKeys(this.typeSelected)
|
||||
}
|
||||
}
|
||||
|
||||
@ -669,32 +666,36 @@ export default class extends Vue {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// begin of award list
|
||||
private async getCouponList(shop: string) {
|
||||
const { data } = await getCoupons({shop})
|
||||
const { data } = await getCoupons({ shop })
|
||||
this.coupons = data.records
|
||||
}
|
||||
|
||||
private formatCoupon(row: number, column: number, cellValue: string, index: number) {
|
||||
let result = `未知(${cellValue})`
|
||||
let data = this.postForm.rewardInfo[index]
|
||||
const data = this.postForm.rewardInfo[index]
|
||||
for (const dep of this.coupons) {
|
||||
if (dep._id == cellValue) {
|
||||
if (dep._id === cellValue) {
|
||||
result = dep.name
|
||||
break
|
||||
}
|
||||
}
|
||||
return `${result} x ${data.count}`
|
||||
}
|
||||
|
||||
private formatRank(row: number, column: number, cellValue: string, index: number) {
|
||||
let data = this.postForm.rewardInfo[index]
|
||||
const data = this.postForm.rewardInfo[index]
|
||||
let result = `第 ${data.rank} 名`
|
||||
if (data.rankEnd) {
|
||||
result = `第 ${data.rank} 至 ${data.rankEnd} 名`
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private async deleteRank(scope: any) {
|
||||
const { $index, row } = scope
|
||||
const { $index } = scope
|
||||
try {
|
||||
await this.$confirm('Confirm to remove the record?', 'Warning', {
|
||||
confirmButtonText: 'Confirm',
|
||||
@ -709,8 +710,8 @@ export default class extends Vue {
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private handleCreateReward() {
|
||||
this.record = Object.assign({}, defaultRewardData)
|
||||
this.record.id = this.postForm.rewardInfo.length
|
||||
@ -721,16 +722,17 @@ export default class extends Vue {
|
||||
private handleEdit(scope: any) {
|
||||
this.dialogType = 'edit'
|
||||
this.dialogVisible = true
|
||||
this.checkStrictly = true
|
||||
this.record = cloneDeep(scope.row)
|
||||
}
|
||||
|
||||
private closeModal() {
|
||||
this.dialogVisible = false
|
||||
this.$refs.modalForm.clearValidate()
|
||||
}
|
||||
|
||||
private saveReward() {
|
||||
const isEdit = this.dialogType === 'edit'
|
||||
this.$refs.modalForm.validate(async(valid: boolean) => {
|
||||
const isEdit = this.dialogType === 'edit';
|
||||
(this.$refs.modalForm as HTMLFormElement).validate(async(valid: boolean) => {
|
||||
if (!valid) {
|
||||
this.$message.error('请按要求填写表单')
|
||||
return false
|
||||
@ -760,28 +762,4 @@ export default class extends Vue {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.createPost-container {
|
||||
position: relative;
|
||||
|
||||
.createPost-main-container {
|
||||
padding: 40px 45px 20px 50px;
|
||||
|
||||
.postInfo-container {
|
||||
position: relative;
|
||||
@include clearfix;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.postInfo-container-item {
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.word-counter {
|
||||
width: 40px;
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -159,7 +159,7 @@ export default class extends Vue {
|
||||
private total = 0
|
||||
private list: IQuestionData[] = []
|
||||
private listLoading = true
|
||||
private allDepts = []
|
||||
private allDepts: IShopData[] = []
|
||||
private listQuery = {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
|
@ -94,12 +94,9 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import { IShopData } from '@/api/types'
|
||||
import Pagination from '@/components/Pagination/index.vue'
|
||||
import { deleteShop, getShops } from '@/api/shop'
|
||||
import { parseTime } from '@/utils'
|
||||
import { Form } from 'element-ui'
|
||||
import { deleteCoupon, getCoupons } from '@/api/coupon'
|
||||
import { deleteGame, getGames, IGameData } from '@/api/game'
|
||||
|
||||
@Component({
|
||||
|
@ -86,7 +86,6 @@ export default class extends Vue {
|
||||
private total = 0
|
||||
private list: IGameData[] = []
|
||||
private listLoading = true
|
||||
private loading = false
|
||||
private shop = ''
|
||||
private allDepts = []
|
||||
private gameid = ''
|
||||
@ -98,7 +97,6 @@ export default class extends Vue {
|
||||
hasVersion: 1
|
||||
}
|
||||
|
||||
private value1 = true
|
||||
|
||||
async created() {
|
||||
await this.getList()
|
||||
|
@ -121,7 +121,7 @@
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import { IShopData } from '@/api/types'
|
||||
import Pagination from '@/components/Pagination/index.vue'
|
||||
import { deleteShop, getShops } from '@/api/shop'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { parseTime } from '@/utils'
|
||||
import { Form } from 'element-ui'
|
||||
import { deleteCoupon, getCoupons } from '@/api/coupon'
|
||||
|
@ -134,7 +134,7 @@ import Sticky from '@/components/Sticky/index.vue'
|
||||
import UploadImage from '@/components/UploadImage/index.vue'
|
||||
import Tinymce from '@/components/Tinymce/index.vue'
|
||||
import { Form } from 'element-ui'
|
||||
import { getShop, getShops } from '@/api/shop'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { defaultCouponData, getCoupon, saveCoupon } from '@/api/coupon'
|
||||
|
||||
@Component({
|
||||
@ -195,11 +195,6 @@ export default class extends Vue {
|
||||
this.tempTagView = Object.assign({}, this.$route)
|
||||
}
|
||||
|
||||
deactivated() {
|
||||
}
|
||||
|
||||
activated() {
|
||||
}
|
||||
|
||||
@Watch('dataRange')
|
||||
private onDataRangeChange(val: Date[]) {
|
||||
|
@ -106,7 +106,7 @@
|
||||
filterable
|
||||
size="medium"
|
||||
style="width: 50%"
|
||||
v-on:change="typechange">
|
||||
v-on:change="typeChange">
|
||||
</el-cascader-panel>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -182,10 +182,14 @@ import Tinymce from '@/components/Tinymce/index.vue'
|
||||
import UploadImage from '@/components/UploadImage/index.vue'
|
||||
import { Form } from 'element-ui'
|
||||
import {
|
||||
defaultQuestionData, deleteQuestion, getAllCategory,
|
||||
defaultQuestionData,
|
||||
deleteQuestion,
|
||||
getAllCategory,
|
||||
getAllTags,
|
||||
getQuestion, nextQuestion,
|
||||
saveQuestion, saveTag
|
||||
getQuestion,
|
||||
nextQuestion,
|
||||
saveQuestion,
|
||||
saveTag
|
||||
} from '@/api/question'
|
||||
|
||||
@Component({
|
||||
@ -248,12 +252,6 @@ export default class extends Vue {
|
||||
this.getRemoteCategory()
|
||||
}
|
||||
|
||||
deactivated() {
|
||||
}
|
||||
|
||||
activated() {
|
||||
}
|
||||
|
||||
private async fetchData(id: string) {
|
||||
try {
|
||||
const { data } = await getQuestion(id, { /* Your params here */ })
|
||||
@ -282,7 +280,7 @@ export default class extends Vue {
|
||||
document.title = `${title} - ${this.postForm._id}`
|
||||
}
|
||||
|
||||
private typechange(val: string[]) {
|
||||
private typeChange(_: string[]) {
|
||||
this.postForm.tag = this.typeSelect[0]
|
||||
this.postForm.sub_tag = this.typeSelect[1]
|
||||
}
|
||||
|
@ -131,13 +131,13 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import { IShopData } from '@/api/types'
|
||||
import Pagination from '@/components/Pagination/index.vue'
|
||||
import { deleteShop, getShops } from '@/api/shop'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { parseTime } from '@/utils'
|
||||
import { Form } from 'element-ui'
|
||||
import {
|
||||
deleteQuestion, getAllCategory,
|
||||
deleteQuestion,
|
||||
getAllCategory,
|
||||
getAllTags,
|
||||
getQuestions,
|
||||
IQuestionData
|
||||
|
@ -40,7 +40,6 @@
|
||||
ref="tree"
|
||||
highlight-current
|
||||
:default-checked-keys="typeSelected"
|
||||
@node-click="nodeClickButton"
|
||||
:props="defaultProps">
|
||||
</el-tree>
|
||||
</el-col>
|
||||
@ -52,13 +51,10 @@
|
||||
import { Component, Vue, Watch } from 'vue-property-decorator'
|
||||
import { getGames, IGameData } from '@/api/game'
|
||||
import Sticky from '@/components/Sticky/index.vue'
|
||||
import {
|
||||
getShopGameInfo,
|
||||
getShops,
|
||||
saveShopGameInfo,
|
||||
updateShopQtypes
|
||||
} from '@/api/shop'
|
||||
import { getShopGameInfo, getShops, updateShopQtypes } from '@/api/shop'
|
||||
import { getAllCategory } from '@/api/question'
|
||||
import { ElTree } from 'element-ui/types/tree'
|
||||
import { IShopData } from '@/api/types'
|
||||
|
||||
@Component({
|
||||
name: 'QuestionSetting',
|
||||
@ -76,7 +72,7 @@ export default class extends Vue {
|
||||
private list: IGameData[] = []
|
||||
private loading = true
|
||||
private shop = ''
|
||||
private allDepts = []
|
||||
private allDepts: IShopData[] = []
|
||||
private gameid = ''
|
||||
private versionid = ''
|
||||
private listQuery = {
|
||||
@ -86,13 +82,17 @@ export default class extends Vue {
|
||||
hasVersion: 1
|
||||
}
|
||||
|
||||
private typeSelected = []
|
||||
private typeSelected: string[] = []
|
||||
private typeOptions: {id: string, label: string, children?: any[]}[] = []
|
||||
private defaultProps = {
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
}
|
||||
|
||||
$refs!: {
|
||||
tree: ElTree<any, any>
|
||||
}
|
||||
|
||||
async created() {
|
||||
await this.getList()
|
||||
await this.getRemoteDeptList('')
|
||||
@ -103,8 +103,8 @@ export default class extends Vue {
|
||||
private onShopChange() {
|
||||
if (this.shop) {
|
||||
let currentShop
|
||||
for (let p of this.allDepts) {
|
||||
if (p._id == this.shop) {
|
||||
for (const p of this.allDepts) {
|
||||
if (p._id === this.shop) {
|
||||
currentShop = p
|
||||
break
|
||||
}
|
||||
@ -191,11 +191,9 @@ export default class extends Vue {
|
||||
|
||||
}
|
||||
}
|
||||
private nodeClickButton(data) {
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
private async saveVal() {
|
||||
if (!this.shop ) {
|
||||
if (!this.shop) {
|
||||
this.$message({
|
||||
message: '选择需要保存的店铺信息',
|
||||
type: 'warning'
|
||||
@ -203,7 +201,7 @@ export default class extends Vue {
|
||||
return
|
||||
}
|
||||
try {
|
||||
let types = this.$refs.tree.getCheckedKeys()
|
||||
const types = this.$refs.tree.getCheckedKeys()
|
||||
const data = {
|
||||
shopid: this.shop,
|
||||
qtypes: types
|
||||
|
@ -170,11 +170,6 @@ export default class extends Vue {
|
||||
this.tempTagView = Object.assign({}, this.$route)
|
||||
}
|
||||
|
||||
deactivated() {
|
||||
}
|
||||
|
||||
activated() {
|
||||
}
|
||||
|
||||
private async fetchData(id: string) {
|
||||
try {
|
||||
|
@ -259,6 +259,7 @@ import {
|
||||
} from '@/api/admins'
|
||||
import { IRole } from '@/views/system/role.vue'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { IShopData } from '@/api/types'
|
||||
|
||||
|
||||
|
||||
@ -281,11 +282,8 @@ export default class extends Vue {
|
||||
private pageSize = 5
|
||||
private dataCount = 0
|
||||
private deptListOptions = []
|
||||
private allDepts = []
|
||||
private defaultProps = {
|
||||
children: 'children',
|
||||
label: 'title'
|
||||
}
|
||||
private allDepts: IShopData[] = []
|
||||
|
||||
|
||||
private filterForm = {
|
||||
key: '',
|
||||
|
@ -259,6 +259,7 @@ import {
|
||||
} from '@/api/admins'
|
||||
import { IRole } from '@/views/system/role.vue'
|
||||
import { getShops } from '@/api/shop'
|
||||
import { IShopData } from '@/api/types'
|
||||
|
||||
|
||||
|
||||
@ -281,7 +282,7 @@ export default class extends Vue {
|
||||
private pageSize = 5
|
||||
private dataCount = 0
|
||||
private deptListOptions = []
|
||||
private allDepts = []
|
||||
private allDepts: IShopData[] = []
|
||||
private defaultProps = {
|
||||
children: 'children',
|
||||
label: 'title'
|
||||
|
@ -25,7 +25,7 @@
|
||||
default-expand-all
|
||||
:expand-on-click-node="false"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{node, data}">
|
||||
<span class="custom-tree-node">
|
||||
<span>{{ node.label }}</span>
|
||||
<span class="action">
|
||||
@ -109,18 +109,19 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue, Watch } from 'vue-property-decorator'
|
||||
import { getGames, IGameData } from '@/api/game'
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import Sticky from '@/components/Sticky/index.vue'
|
||||
import {
|
||||
getShopGameInfo,
|
||||
getShops,
|
||||
saveShopGameInfo,
|
||||
updateShopQtypes
|
||||
} from '@/api/shop'
|
||||
import { getAllCategory } from '@/api/question'
|
||||
import { getPermissions, savePermission } from '@/api/permissions'
|
||||
import { Form } from 'element-ui'
|
||||
import { TreeNode } from 'element-ui/types/tree'
|
||||
|
||||
export interface ITreeData{
|
||||
idx?: number
|
||||
parent?: any
|
||||
id: string
|
||||
label: string
|
||||
actions?: string[]
|
||||
children?: ITreeData[]
|
||||
}
|
||||
|
||||
@Component({
|
||||
name: 'PermissionSetting',
|
||||
@ -133,19 +134,21 @@ import { Form } from 'element-ui'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default class extends Vue {
|
||||
private loading = true
|
||||
private shop = ''
|
||||
private dialogType = 'new'
|
||||
private dialogVisible = false
|
||||
private record = {actions: []}
|
||||
private record: ITreeData = { actions: [], id: '', label: '' }
|
||||
private actions = [
|
||||
'read', 'edit', 'delete'
|
||||
]
|
||||
|
||||
$refs!: {
|
||||
modalForm: HTMLFormElement
|
||||
}
|
||||
|
||||
private typeSelected = []
|
||||
private typeOptions: {id: string, label: string, children?: any[]}[] = []
|
||||
private typeOptions: ITreeData[] = []
|
||||
private initAdmin() {
|
||||
return {
|
||||
id: '',
|
||||
@ -153,6 +156,7 @@ export default class extends Vue {
|
||||
actions: []
|
||||
}
|
||||
}
|
||||
|
||||
private modalRules = {
|
||||
id: [{ required: true, message: '请输入权限id', trigger: 'blur' },
|
||||
{ min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur' },
|
||||
@ -170,15 +174,15 @@ export default class extends Vue {
|
||||
pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.·-]+$/,
|
||||
message: '权限名不支持特殊字符',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
}]
|
||||
|
||||
}
|
||||
|
||||
async created() {
|
||||
await this.getRemoteCategory()
|
||||
this.loading = false
|
||||
}
|
||||
|
||||
|
||||
private async onCancel() {
|
||||
try {
|
||||
await this.$confirm('确认不保存当前信息?', 'Warning', {
|
||||
@ -193,28 +197,30 @@ export default class extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
private append(data) {
|
||||
private append(data: ITreeData) {
|
||||
this.record = this.initAdmin()
|
||||
this.dialogType = 'new'
|
||||
this.dialogVisible = true
|
||||
this.record.actions = this.actions
|
||||
this.record.parent = data
|
||||
}
|
||||
private edit(node, data) {
|
||||
|
||||
private edit(node: TreeNode<any, any>, data: ITreeData) {
|
||||
console.log(data)
|
||||
this.record = this.initAdmin()
|
||||
this.record.idx = node.parent.data.children.indexOf(data)
|
||||
this.record.actions = data.children.map(o=>o.label)
|
||||
this.record.parent = node.parent.data
|
||||
this.record.idx = node.parent?.data.children.indexOf(data)
|
||||
this.record.actions = data.children?.map(o => o.label)
|
||||
this.record.parent = node.parent?.data
|
||||
this.dialogType = 'edit'
|
||||
this.dialogVisible = true
|
||||
this.record.id = data.id
|
||||
this.record.label = data.label
|
||||
}
|
||||
private async remove(node, data) {
|
||||
const parent = node.parent.data;
|
||||
const children = parent.children || parent.data;
|
||||
const index = children.findIndex(d => d.id === data.id);
|
||||
|
||||
private async remove(node: TreeNode<any, any>, data: ITreeData) {
|
||||
const parent = node.parent?.data
|
||||
const children: ITreeData[] = parent.children || parent.data
|
||||
const index = children.findIndex(d => d.id === data.id)
|
||||
console.log(node, data)
|
||||
try {
|
||||
await this.$confirm('确认删除此权限?', 'Warning', {
|
||||
@ -222,23 +228,23 @@ export default class extends Vue {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
children.splice(index, 1);
|
||||
} catch(err) {
|
||||
children.splice(index, 1)
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async saveVal() {
|
||||
try {
|
||||
let records = []
|
||||
for (let data of this.typeOptions[0].children) {
|
||||
const records = []
|
||||
for (const data of this.typeOptions[0].children!) {
|
||||
records.push({
|
||||
_id: data.id,
|
||||
name: data.label,
|
||||
actions: data.children.map(o => o.label)
|
||||
actions: data.children?.map(o => o.label)
|
||||
})
|
||||
}
|
||||
await savePermission({datas: records})
|
||||
await savePermission({ datas: records })
|
||||
console.log(records)
|
||||
this.$notify({
|
||||
title: 'Success',
|
||||
@ -260,27 +266,28 @@ export default class extends Vue {
|
||||
children: data
|
||||
})
|
||||
}
|
||||
|
||||
private closeModal() {
|
||||
this.dialogVisible = false
|
||||
this.$refs.modalForm.clearValidate()
|
||||
}
|
||||
|
||||
private async savePermission() {
|
||||
const form = <Form>this.$refs.modalForm
|
||||
try {
|
||||
await form.validate()
|
||||
await this.$refs.modalForm.validate()
|
||||
const subArr = []
|
||||
for (const s of this.record.actions) {
|
||||
for (const s of this.record.actions!) {
|
||||
subArr.push({
|
||||
id: `${this.record.id}:${s}`,
|
||||
label: s
|
||||
})
|
||||
}
|
||||
let data = {
|
||||
const data = {
|
||||
id: this.record.id,
|
||||
label: this.record.label,
|
||||
children: subArr
|
||||
}
|
||||
if (this.dialogType == 'new') {
|
||||
if (this.dialogType === 'new') {
|
||||
this.record.parent.children.push(data)
|
||||
} else {
|
||||
this.record.parent.children.splice(this.record.idx, 1, data)
|
||||
@ -291,8 +298,6 @@ export default class extends Vue {
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user