Commit 84e3eb11 by cwq0219
2 parents 79f06e94 14864aa8
import request from './request'
const path = 'org.ore.api.accountType.'
const accountApi = {
/** 账户类型分页数据*/
getPageApi(data = {}) {
data.method = `${path}page`
return request(data)
},
/** 账户类型列表 */
getList(data = {}) {
data.method = `${path}list`
return request(data)
},
/** 删除账户类型 */
delete(data = {}) {
data.method = `${path}deleteById`
return request(data)
},
/** 根据id获取账户类型 */
getById(data = {}) {
data.method = `${path}getById`
return request(data)
},
/** 新增账户类型 */
insert(data = {}) {
data.method = `${path}insert`
return request(data)
},
/** 编辑账户类型 */
update(data = {}) {
data.method = `${path}update`
return request(data)
}
}
export { accountApi }
import request from './request'
const path = 'cn.com.glsx.merchants.menu.'
const dictApi = {
/** 查询字典类型*/
findDictType(data = {}) {
data.method = `${path}findDictType`
return request(data)
},
/** 删除字典类型 */
deleteDictType(data = {}) {
data.method = `${path}deleteDictType`
return request(data)
},
/** 保存字典类型 */
saveDictType(data = {}) {
data.method = `${path}saveDictType`
return request(data)
},
/** 更新字典类型 */
updateDictType(data = {}) {
data.method = `${path}updateDictType`
return request(data)
},
/** 查询字典数据列表 */
findDictData(data = {}) {
data.method = `${path}findDictData`
return request(data)
},
/** 删除字典数据 */
deleteDictData(data = {}) {
data.method = `${path}deleteDictData`
return request(data)
},
/** 保存字典数据 */
saveDictData(data = {}) {
data.method = `${path}saveDictData`
return request(data)
},
/** 更新字典数据 */
updateDictData(data = {}) {
data.method = `${path}updateDictData`
return request(data)
}
}
export { dictApi }
...@@ -10,14 +10,23 @@ import { Request as request } from 'glsx-vue-common' ...@@ -10,14 +10,23 @@ import { Request as request } from 'glsx-vue-common'
import '@/styles/index.scss' import '@/styles/index.scss'
// 组件 // 组件
import '@/components' import '@/components'
import { Common } from '@/utils/common.js'
import Constants from '@/utils/constants.js'
import _ from 'lodash' import _ from 'lodash'
// import axios from 'axios' // import axios from 'axios'
Vue.prototype.btn_size = 'mini' Vue.prototype.btn_size = 'mini'
Vue.prototype.$Common = Common
Vue.prototype.$Constants = Constants
Vue.use(ElementUI) Vue.use(ElementUI)
Vue.use(glsxTable) Vue.use(glsxTable)
var mixin = { var mixin = {
data() {
return {
flag: true,
eventBus: new Vue()
}
},
mounted() { mounted() {
const _this = this const _this = this
const theme = new this.$Theme() const theme = new this.$Theme()
...@@ -28,16 +37,40 @@ var mixin = { ...@@ -28,16 +37,40 @@ var mixin = {
}, },
height() { height() {
return document.height || document.body.offsetHeight // document.documentElement.clientHeight || document.body.clientHeight // return document.height || document.body.offsetHeight // document.documentElement.clientHeight || document.body.clientHeight //
},
translate(params) {
_this.eventBus.$emit('params', params)
} }
} }
}) })
connection.promise.then(parent => { connection.promise.then(parent => {
const cfg = _this.$get_session_config() const cfg = _this.$get_session_config()
_this.$$parent = parent
if (cfg) return if (cfg) return
parent.getResources().then(config => { parent.getResources().then(config => {
_this.$set_session_config(config) _this.$set_session_config(config)
}) })
}) })
},
methods: {
/**
* 页面跳转方法 用法 :
* this.$root.to(['MOCK系统A', '一键导航', '导航数据', 'MOCK数据B', 'localhost'],'1123')
* 或:
* this.$parent.to(['MOCK系统A', '一键导航', '导航数据', 'MOCK数据B', 'localhost'],'1123')
*
* @param {*} path 如: ['一级菜单名称','二级菜单名称','三级菜单名称','四级菜单名称','五级菜单名称']
* @param {*} params 传给下一个页面的参数
*/
to(path, params) {
if (this.$$parent) {
this.$$parent.to(path, params)
} else {
this.$$connection.promise.then(parent => {
parent.to(path, params)
})
}
}
} }
} }
const URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config' const URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config'
......
<template>
<div>
<el-dialog
:title="title"
:visible.sync="isVisible"
:before-close="handleClose"
:close-on-click-modal="false"
:width="width"
class="app-dialog"
>
<div class="container">
<slot></slot>
</div>
<div slot="footer">
<slot name="btn-front"></slot>
<el-button @click="handleClose">取消</el-button>
<el-button
type="primary"
@click="handleConfirm"
:loading="btnLoading"
>{{btnOkLabel}}</el-button>
<slot name="btn-behind"></slot>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'basic-dialog',
props: {
title: {
type: String,
default: ''
},
isVisible: {
type: Boolean,
default: false
},
btnOkLabel: {
type: String,
default: '确定'
},
width: {
type: String,
default: '580px'
},
btnLoading: {
type: Boolean,
default: false
}
},
methods: {
handleClose() {
this.$emit('closeDialog')
},
handleConfirm() {
this.$emit('confirmDialog')
}
}
}
</script>
<style lang="scss">
.app-dialog {
.el-dialog__header {
padding: 20px;
}
.el-dialog__footer {
padding: 10px;
background: #fff;
}
.el-dialog__body {
padding: 0;
border-top: 1px solid #eaeefb;
border-bottom: 1px solid #eaeefb;
min-height: 250px;
max-height: 500px;
overflow-y: auto;
.container {
> span {
display: block;
}
overflow-y: auto;
padding: 20px 20px;
}
}
}
</style>
...@@ -2,5 +2,7 @@ import Vue from 'vue' ...@@ -2,5 +2,7 @@ import Vue from 'vue'
// 注意 有些组件使用异步加载会有影响 // 注意 有些组件使用异步加载会有影响
Vue.component('d2-table', () => import('./d2-table/index.vue')) Vue.component('d2-table', () => import('./d2-table/index.vue'))
Vue.component('basic-dialog', () => import('./basic-dialog/index.vue'))
Vue.component('rule-form', () => import('./rule-form/index.vue'))
Vue.component('glsx-dialog', () => import('./glsx-dialog/index.vue')) Vue.component('glsx-dialog', () => import('./glsx-dialog/index.vue'))
Vue.component('glsx-combi-form', () => import('./glsx-combi-form/index.vue')) Vue.component('glsx-combi-form', () => import('./glsx-combi-form/index.vue'))
<template>
<div>
<el-form
:model="ruleForm"
:rules="rules"
:label-position="labelPosition"
:label-width="labelWidth"
:size="size"
>
<el-form-item
v-for="(item, index) in ruleData"
:key="index"
:label="item.label"
:prop="item.prop || ''"
:class="item.class"
v-show="!item.hidden"
>
<template slot-scope="scope">
<template v-if="item.type === 'input'">
<el-input
v-if="item.clickFunc"
:type="item.inputText || 'text'"
:readonly="item.readonly || false"
@click.native="item.clickFunc"
:class="item.clickFunc ? 'pointer' : ''"
:ref="item.ref"
v-model="ruleForm[item.prop]"
@input="update($event)"
>
</el-input>
<el-input
v-else
:type="item.inputText || 'text'"
:readonly="item.readonly || false"
:disabled="item.disabled || false"
v-model="ruleForm[item.prop]"
:maxlength="item.maxlength"
:minlength="item.minlength"
:show-password="item.showPassword || false"
:clearable="item.clearable"
:show-word-limit="item.showWordLimit || false"
>
</el-input>
</template>
<template v-else-if="item.type == 'select'">
<el-select
v-if="item.visibleFunc"
v-model="ruleForm[item.prop]"
:placeholder="item.placeholder || '请选择'"
:filterable="item.filterable || false"
@change="selectChange"
@visible-change="item.visibleFunc"
>
<el-option
v-for="i in item.options"
:key="i[item.value] || i.value"
:label="i[item.key] || i.label"
:value="i[item.value] || i.value"
:disabled="i.disabled"
>
</el-option>
</el-select>
<el-select
v-else
v-model="ruleForm[item.prop]"
:placeholder="item.placeholder || '请选择'"
:filterable="item.filterable || false"
@change="selectChange"
>
<el-option
v-for="i in item.options"
:key="i[item.value] || i.value"
:label="i[item.key] || i.label"
:value="i[item.value] || i.value"
:disabled="i.disabled"
>
</el-option>
</el-select>
</template>
<template v-else-if="item.type === 'switch'">
<el-switch
v-model="ruleForm[item.prop]"
:active-text="item.activeText || '开'"
:inactive-text="item.inactiveText || '关'"
></el-switch>
</template>
<template v-else-if="item.type === 'radio'">
<el-radio-group
@change="radioChange($event,item.prop)"
v-model="ruleForm[item.prop]"
:disabled="item.disabled"
>
{{ruleForm[item.prop]}}
<el-radio
v-for="(child,childIndex) in item.children"
:key="childIndex"
:label="childIndex"
>{{child}}</el-radio>
</el-radio-group>
<el-select
v-if="item.hasSelect"
v-model="ruleForm[item.prop]"
:placeholder="item.placeholder || '请选择'"
@change="selectChange"
>
<el-option
v-for="i in item.options"
:key="i[item.value] || i.value"
:label="i[item.key] || i.label"
:value="i[item.value] || i.value"
:disabled="i.disabled"
>
</el-option>
</el-select>
</template>
<template v-else-if="item.type == 'customize'">
<slot
:scope="scope"
:name="item.slotName"
>
</slot>
</template>
</template>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
name: 'rule-form',
data() {
return {
// labelPosition: 'left'
}
},
props: {
// 表单数据
ruleData: {
type: Array,
default: () => {
return []
}
},
// 表单model
ruleForm: {
type: Object,
default: () => {
return {}
}
},
// 表单验证规则
rules: {
type: Object,
default: () => {
return {}
}
},
// 标签位置
labelPosition: {
type: String,
default: 'right'
},
size: {
type: String,
default: 'small'
},
labelWidth: {
type: String,
default: '100px'
}
},
mounted() {
},
methods: {
selectChange(val) {
this.$emit('selectChange', val)
},
radioChange(event, prop) {
this.$emit('radioChange', event, prop)
},
update(e) {
this.$forceUpdate()
}
}
}
</script>
<style lang="scss">
.pointer input {
cursor: pointer;
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -81,3 +81,49 @@ a:hover { ...@@ -81,3 +81,49 @@ a:hover {
.el-table .cell { .el-table .cell {
padding: 0 0; padding: 0 0;
} }
// 状态
.dot {
display: inline-block;
width: 7px;
height: 7px;
border-radius: 5px;
vertical-align: middle;
margin-right: 2px;
}
.green-text {
color: #00A854;
}
.red-text {
color: rgb(255, 0, 0);
}
.green {
background-color: #00A854;
}
.gray {
background-color: #BFBFBF;
}
.blue {
background-color: rgb(0, 81, 255);
}
.red {
background-color: rgb(255, 0, 0);
}
.yellow {
background-color: rgb(217, 255, 0);
}
.orange {
background-color: rgb(255, 145, 0);
}
.statusText {
vertical-align: middle;
}
\ No newline at end of file \ No newline at end of file
export const Common = {
// 提示框
confirmDialog: (tipData) => {
tipData.that.$confirm(tipData.tipText, tipData.tipTitle, {
confirmButtonText: tipData.confirmButtonText || '确定',
cancelButtonText: tipData.cancelButtonText || '取消',
type: tipData.type,
showCancelButton: tipData.showCancelButton
}).then(() => {
tipData.callBack ? tipData.callBack() : ''
}).catch(() => {
tipData.errorCallBack ? tipData.errorCallBack() : ''
})
}
}
const Constants = {
// 字典状态
DICT_STATUS: {
'1': '启用, green',
'2': '停用, red'
},
ACCOUNT_STAUS: {
'0': '正常',
'1': '草稿'
},
DICT_STATUS_OPTIONS: [
{
label: '启用',
value: 1
},
{
label: '停用',
value: 2
}
]
}
export default Constants
...@@ -147,21 +147,25 @@ export default { ...@@ -147,21 +147,25 @@ export default {
} }
}, },
mounted() { mounted() {
this.accountRuleForm = { this.$root.eventBus.$on('params', (params) => {
accounttypeName: '12121', console.log(params)
accounttypeDetail: '232223', })
accounttypeCode: [{ // this.accountRuleForm = {
value: 1, // accounttypeName: '12121',
label: '嘀加智慧门店PC后台' // accounttypeDetail: '232223',
}, { // accounttypeCode: [{
value: 2, // value: 1,
label: '嘀加智享车生活PC后台' // label: '嘀加智慧门店PC后台'
}] // }, {
} // value: 2,
// label: '嘀加智享车生活PC后台'
// }]
// }
}, },
methods: { methods: {
// 功能权限切换 // 功能权限切换
handleClick(tab, event) { handleClick(tab, event) {
this.addStyle()
}, },
// 渲染树结构 // 渲染树结构
renderContent(h, v) { renderContent(h, v) {
...@@ -211,6 +215,8 @@ export default { ...@@ -211,6 +215,8 @@ export default {
case 'save': case 'save':
break break
case 'cancel': case 'cancel':
window.href = ""
// this.$parent.to(['MOCK系统G', '系统设置', '账户管理', '账户类型管理', '账户类型列表'])
break break
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<template> <template>
<div> <div>
<el-form :inline="true" :model="accountSearchForm"> <el-form :inline="true" :model="accountSearchForm">
<el-form-item> <el-form-item label="账户状态:">
<el-select <el-select
v-model="accountSearchForm.value" v-model="accountSearchForm.value"
:size="btn_size" :size="btn_size"
...@@ -17,32 +17,32 @@ ...@@ -17,32 +17,32 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="账户类型名称:">
<el-input v-model="accountSearchForm.input" :size="btn_size" placeholder="请输入内容"></el-input> <el-input v-model="accountSearchForm.input" :size="btn_size" placeholder="请输入内容"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" :size="btn_size" :id="accountTableParams.btnId">搜索</el-button> <el-button type="primary" :size="btn_size" :id="accountTableParams.btnId">搜索</el-button>
<el-button type="primary" :size="btn_size">添加账户类型</el-button> <el-button type="primary" :size="btn_size" @click="btnClick('create')">添加账户类型</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<d2-table :searchForm="accountSearchForm" :tableData="tableData" :tableParams="accountTableParams"> <d2-table :searchForm="accountSearchForm" :getListApi="getListApi" :tableParams="accountTableParams">
<div slot="auth-button" slot-scope="scope"> <div slot="auth-button" slot-scope="scope">
<el-button <el-button
type="text" type="text"
:size="btn_size" :size="btn_size"
@click="btnClick(scope.scope, 'view')" @click="btnClick()"
>查看详情</el-button >查看详情</el-button
> >
<el-button <el-button
type="text" type="text"
:size="btn_size" :size="btn_size"
@click="btnClick(scope.scope, 'edit')" @click="btnClick('edit', scope.scope)"
>修改</el-button >修改</el-button
> >
<el-button <el-button
type="text" type="text"
:size="btn_size" :size="btn_size"
@click="btnClick(scope.scope, 'delete')" @click="btnClick('delete', scope.scope)"
>删除</el-button >删除</el-button
> >
</div> </div>
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
</template> </template>
<script> <script>
import { accountApi } from '@/api/accountManage'
export default { export default {
data() { data() {
return { return {
...@@ -58,25 +59,29 @@ export default { ...@@ -58,25 +59,29 @@ export default {
tableData: [{ tableData: [{
name: 'dsfd' name: 'dsfd'
}], }],
getListApi: accountApi.getPageApi,
accountTableParams: { accountTableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000), btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list', listName: 'data.data',
tableColumns: [ tableColumns: [
{ {
label: '账户类型ID', label: '账户类型ID',
prop: '' prop: 'accounttypeCode'
}, },
{ {
label: '账户类型名称', label: '账户类型名称',
prop: 'name' prop: 'accounttypeName'
}, },
{ {
label: '更新时间', label: '更新时间',
prop: '' prop: 'updatedTime'
}, },
{ {
label: '状态', label: '状态',
prop: '' prop: 'delFlag',
formatter: cellValue => {
return this.$Constants.ACCOUNT_STAUS[cellValue.delFlag]
}
} }
], ],
tableOption: true tableOption: true
...@@ -85,9 +90,11 @@ export default { ...@@ -85,9 +90,11 @@ export default {
} }
}, },
methods: { methods: {
btnClick(scope, type) { btnClick(type, scope) {
switch (type) { switch (type) {
case 'create': case 'create':
console.log('create')
this.$root.to(['商户账号系统', '系统设置', '账户管理', '账户类型管理', '*新增账户类型'], { id: 1 })
break break
case 'edit': case 'edit':
break break
......
import App from './index.vue'
import base from '@/base'
import GlsxVueCommon from 'glsx-vue-common'
base.getConfig().then(data => {
const { vue, config } = data
vue.use(GlsxVueCommon, config)
base.render(App)
})
<template>
<div>
<el-form :inline="true" :model="dictDataSearchForm">
<el-form-item>
<el-input
v-model="dictDataSearchForm.dictName"
:size="btn_size"
placeholder="请输入字典名称"
></el-input>
</el-form-item>
<el-form-item>
<el-input
v-model="dictDataSearchForm.dictType"
:size="btn_size"
readonly
placeholder="请输入字典类型"
></el-input>
</el-form-item>
<el-form-item>
<el-select
v-model="dictDataSearchForm.enableStatus"
:size="btn_size"
placeholder="请选择字典状态"
>
<el-option
v-for="item in $Constants.DICT_STATUS_OPTIONS"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
:size="btn_size"
:id="dictDataTableParams.btnId"
>搜索</el-button
>
<el-button type="primary" :size="btn_size" @click="btnClick('create')"
>新增字典数据</el-button
>
</el-form-item>
</el-form>
<d2-table
ref="dictDataTable"
:tableParams="dictDataTableParams"
:searchForm="dictDataSearchForm"
:getListApi="getListApi"
>
<span slot="auth-button" slot-scope="scope">
<el-button
v-for="(j, idx) in dictDataTableParams.tableOption.btnList"
:key="idx"
:type="j.type || 'text'"
:size="btn_size"
@click="btnClick(j.pType, scope.scope)"
>{{ j.name }}</el-button
>
</span>
</d2-table>
<basic-dialog
:title="dictDataDialogTitle"
:isVisible="dictDataVisible"
@confirmDialog="handleConfirm"
@closeDialog="handleClose"
>
<slot>
<rule-form
:ruleForm="dictDataForm"
:rules="dictDataRules"
:ruleData="dictDataData"
ref="dictDataForm"
></rule-form>
</slot>
</basic-dialog>
</div>
</template>
<script>
import { dictApi } from '@/api/dictManage'
export default {
data() {
return {
dictDataSearchForm: {
dictType: 'functional_attributes'
},
dictDataTableData: [
{
id: 1,
dictName: 'dasf'
}
],
getListApi: dictApi.findDictData,
dictDataTableParams: {
numName: '字典编码',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'data.data',
tableColumns: [
{
label: '字典标签',
prop: 'dictLabel'
},
{
label: '字典键值',
prop: 'dictValue'
},
{
label: '字典排序',
prop: 'dictSort'
},
{
label: '备注',
prop: 'remark'
},
{
label: '字典状态',
prop: 'enableStatus',
addHtml: 'status'
},
{
label: '创建时间',
prop: 'createdDate'
}
],
tableOption: {
width: 140,
btnList: [
{
name: '编辑',
pType: 'edit'
},
{
name: '删除',
pType: 'delete'
}
]
}
},
// 弹窗
dictDataDialogTitle: '新增字典',
dictDataVisible: false,
dictDataForm: {},
dictDataData: [
{
label: '字典类型:',
prop: 'dictType',
type: 'input',
readonly: true
},
{
label: '字典标签:',
prop: 'dictLabel',
type: 'input',
maxlength: 20
},
{
label: '字典键值:',
prop: 'dictValue',
type: 'input',
maxlength: 50
},
{ label: '字典排序:', prop: 'dictSort', type: 'input', maxlength: 5 },
{ label: '状态:', prop: 'enableStatus', type: 'switch' },
{
label: '备注:',
prop: 'remark',
type: 'input',
inputText: 'textarea',
maxlength: 200,
showWordLimit: true
}
],
dictDataRules: {
dictType: [{ required: true }],
dictLabel: [
{ required: true, message: '请输入字典标签', trigger: 'blur' }
],
dictValue: [
{ required: true, message: '请输入字典键值', trigger: 'blur' }
],
dictSort: [
{ required: true, message: '请输入字典排序', trigger: 'blur' },
{ validator: this.$Common.checkRegExpNumber, trigger: 'blur' }
],
enableStatus: [{ required: true }]
},
dictData: {}
}
},
mounted() {
this.$root.eventBus.$on('params', (params) => {
console.log(params)
this.dictDataSearchForm.dictType = params.dictType
this.dictData = params
})
},
methods: {
// 确定
handleConfirm() {
this.$refs.dictDataForm.$children[0].validate(valid => {
if (valid) {
let params = JSON.parse(JSON.stringify(this.dictDataForm))
params.enableStatus = this.dictDataForm.enableStatus ? 1 : 2
// let api = addDictData
// if (params.id) {
// api = editDictData
// delete params.delFlag
// delete params.disabled
// delete params.deleted
// delete params.typeDeleted
// delete params.typeDisabled
// }
// api(params).then(res => {
// if (res.code == 200) {
// this.$message({
// type: 'success',
// message: '操作成功!'
// })
// this.handleClose()
// this.$refs.dictDataTable.refreshTable()
// } else {
// this.$message({
// type: 'error',
// message: res.message
// })
// }
// })
}
})
},
// 取消
handleClose() {
if (!this.dictDataVisible && this.$refs.dictDataForm) {
this.$refs.dictDataForm.$children[0].resetFields()
}
this.dictDataVisible = !this.dictDataVisible
},
// 按钮事件
btnClick(pType, scope) {
switch (pType) {
case 'create':
this.dictDataDialogTitle = '新增字典'
// const params = this.getInitStorage()
this.dictDataForm = {
dictType: this.dictData.dictType,
enableStatus: params.row.enableStatus == 1
}
this.handleClose()
break
case 'edit':
this.dictDataDialogTitle = '编辑字典'
this.editEvent(scope)
break
case 'delete':
this.deleteEvent(scope.id)
break
}
},
// 编辑触发事件
editEvent(row) {
this.dictDataForm = JSON.parse(JSON.stringify(row))
this.dictDataForm.enableStatus = row.enableStatus == 1 ? true : false
delete this.dictDataForm.createdDate
delete this.dictDataForm.isDefault
this.handleClose()
},
// 删除触发事件
deleteEvent(id) {
const that = this
const tipData = {
that: that,
tipText: '是否删除当前记录',
tipTitle: '提示',
type: 'warning',
callBack: () => {
const params = {
dataId: id
}
console.log(params)
// deleteDictData(params).then(res => {
// if (res.code == 200) {
// this.$message({
// type: 'success',
// message: '删除成功!'
// })
// this.$refs.dictDataTable.refreshTable()
// } else {
// this.$message({
// type: 'error',
// message: res.message
// })
// }
// })
}
}
this.$Common.confirmDialog(tipData)
}
}
}
</script>
import App from './index.vue'
import base from '@/base'
import GlsxVueCommon from 'glsx-vue-common'
base.getConfig().then(data => {
const { vue, config } = data
vue.use(GlsxVueCommon, config)
base.render(App)
})
<template>
<div>
<el-form :inline="true" :model="dictSearchForm">
<el-form-item label="字典名称:">
<el-input v-model="dictSearchForm.name" :size="btn_size" placeholder="请输入字典名称"></el-input>
</el-form-item>
<el-form-item label="字典类型:">
<el-input v-model="dictSearchForm.type" :size="btn_size" placeholder="请输入字典类型"></el-input>
</el-form-item>
<el-form-item label="字典状态:">
<el-select
v-model="dictSearchForm.enableStatus"
:size="btn_size"
placeholder="请选择字典状态"
>
<el-option
v-for="item in $Constants.DICT_STATUS_OPTIONS"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" :size="btn_size" :id="dictTableParams.btnId">搜索</el-button>
<el-button type="primary" :size="btn_size" @click="btnClick('create')">新增字典</el-button>
</el-form-item>
</el-form>
<d2-table ref="dictTable" :hasNum="false" :tableParams="dictTableParams" :searchForm="dictSearchForm" :getListApi="getListApi">
<span
slot="status"
slot-scope="scope"
>
<span
class="dot"
:class="scope.scope.enableStatus ? DICTSTATUS[scope.scope.enableStatus].split(',')[1] : ''"
></span><span class="statusText">{{ scope.scope.enableStatus ? DICTSTATUS[scope.scope.enableStatus].split(',')[0] : '--'}}</span>
</span>
<span
slot="auth-button"
slot-scope="scope"
>
<el-button
v-for="(j, idx) in dictTableParams.tableOption.btnList"
:key="idx"
:type="j.type || 'text'"
:size="btn_size"
@click="btnClick(j.pType, scope.scope)"
>{{j.name}}</el-button>
</span>
</d2-table>
<basic-dialog
:title="dictionaryDialogTitle"
:isVisible="dictionaryVisible"
@confirmDialog="handleConfirm"
@closeDialog="handleClose"
>
<slot>
<rule-form
:ruleForm="dictionaryForm"
:rules="dictionaryRules"
:ruleData="dictionaryData"
ref='dictionaryForm'
></rule-form>
</slot>
</basic-dialog>
</div>
</template>
<script>
import { dictApi } from '@/api/dictManage'
export default {
data() {
return {
DICTSTATUS: this.$Constants.DICT_STATUS,
dictSearchForm: {},
tableData: [{
id: 1,
dictName: 'dsfd'
}],
getListApi: dictApi.findDictType,
dictTableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'data.data',
tableColumns: [
{
label: '字典主键',
prop: 'id'
}, {
label: '字典名称',
prop: 'dictName'
}, {
label: '字典类型',
prop: 'dictType'
}, {
label: '字典备注',
prop: 'remark'
}, {
label: '字典状态',
prop: 'enableStatus',
addHtml: 'status'
}, {
label: '创建时间',
prop: 'createdDate'
}
],
tableOption: {
width: 150,
btnList: [
{
name: '列表',
pType: 'list'
},
{
name: '编辑',
pType: 'edit'
},
{
name: '删除',
pType: 'delete'
}
]
}
},
// 弹窗
dictionaryDialogTitle: '新增字典',
dictionaryVisible: false,
dictionaryForm: {
enableStatus: true
},
dictionaryData: [
{ label: '字典名称:', prop: 'dictName', type: 'input', maxlength: 20 },
{ label: '字典类型:', prop: 'dictType', type: 'input', maxlength: 50, readonly: false },
{ label: '状态:', prop: 'enableStatus', type: 'switch' },
{ label: '备注:', prop: 'remark', type: 'input', inputText: 'textarea', maxlength: 200, showWordLimit: true }
],
dictionaryRules: {
dictName: [{ required: true, message: '请输入字典名称', trigger: blur }],
dictType: [{ required: true, message: '请输入字典类型', trigger: blur }],
enableStatus: [{ required: true }]
}
}
},
methods: {
// 确定
handleConfirm() {
console.log(this.dictionaryForm)
this.$refs.dictionaryForm.$children[0].validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.dictionaryForm))
params.enableStatus = this.dictionaryForm.enableStatus ? 1 : 2
console.log(params)
let api = 'saveDictType'
if (params.id) api = 'updateDictType'
dictApi[api](params).then(res => {
if (res.code == 0) {
this.$message({
type: 'success',
message: '操作成功!'
})
this.$refs.dictTable.refreshTable()
this.handleClose()
} else {
this.$message({
type: 'error',
message: res.message
})
}
})
}
})
},
// 取消
handleClose() {
if (!this.dictionaryVisible && this.$refs.dictionaryForm) {
this.$refs.dictionaryForm.$children[0].resetFields()
}
this.dictionaryVisible = !this.dictionaryVisible
},
// 按钮事件
btnClick(pType, scope) {
console.log(pType, scope)
switch (pType) {
case 'create':
this.dictionaryDialogTitle = '新增字典'
this.dictionaryForm = {
enableStatus: true
}
this.dictionaryData.map(item => {
if (item.prop == 'dictType') {
item.readonly = false
}
})
this.handleClose()
break
case 'edit':
this.dictionaryDialogTitle = '编辑字典'
this.dictionaryData.map(item => {
if (item.prop == 'dictType') {
item.readonly = true
}
})
this.editEvent(scope)
break
case 'delete':
this.deleteEvent(scope.id)
break
case 'list':
this.$root.to(['商户账号系统', '系统设置', '字典管理', '字典类型', '*字典数据'], { id: 1 })
break
}
},
// 编辑触发时间
editEvent(row) {
this.dictionaryForm = JSON.parse(JSON.stringify(row))
this.dictionaryForm.enableStatus = row.enableStatus == 1 ? true : false
delete this.dictionaryForm.createdDate
this.handleClose()
},
// 删除触发事件
deleteEvent(id) {
const that = this
const tipData = {
that: that,
tipText: '是否删除当前记录',
tipTitle: '提示',
type: 'warning',
callBack: () => {
const params = {
id
}
console.log(params)
dictApi.deleteDictData(params).then(res => {
if (res.code == 0) {
this.$message({
type: 'success',
message: '删除成功!'
})
this.$refs.dictTable.refreshTable()
} else {
this.$message({
type: 'error',
message: res.message
})
}
})
}
}
this.$Common.confirmDialog(tipData)
}
}
}
</script>
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
<a href="../customer/account/add.html">添加账户</a> <a href="../customer/account/add.html">添加账户</a>
</li> </li>
<li> <li>
<a href="../customer/dictionaryManage/index.html">字典类型</a>
</li>
<li>
<a href="../customer/dictionaryManage/dictionaryData.html">字典数据</a>
</li>
<li>
<a <a
href="../productManage/productList.html" href="../productManage/productList.html"
target="_self" target="_self"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!