<template>
|
<page-header-wrapper>
|
<a-card :bordered="false">
|
<div class="table-page-search-wrapper">
|
<a-form layout="inline">
|
<a-row :gutter="48">
|
<a-col :md="12" :lg="6" :sm="24">
|
<a-form-item label="描述">
|
<a-input v-model="queryParam.cDesc" style="width: 100%" placeholder="请输入描述" />
|
</a-form-item>
|
</a-col>
|
<a-col :md="12" :lg="6" :sm="24">
|
<a-form-item>
|
<span class="table-page-search-submitButtons">
|
<a-button @click="getqueryParam" icon="redo"> 重置</a-button>
|
<a-button type="primary" icon="search" style="margin-left: 8px" @click="getlist()">查询 </a-button>
|
</span>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
</a-form>
|
</div>
|
</a-card>
|
|
<a-card :bordered="false">
|
<a-table bordered :loading="loading" :columns="columns" :data-source="datalist" rowKey="id">
|
<template slot="cValue" slot-scope="text, record">
|
<div v-if="record.cValueType === 'bool'">{{ text === '1' ? '开启' : '关闭' }}</div>
|
<div v-else>{{ text }}</div>
|
</template>
|
<template slot="action" slot-scope="text, record">
|
<a slot="action" href="javascript:;" @click="geteditStock(record)">{{ '修改记录' }}</a>
|
</template>
|
</a-table>
|
</a-card>
|
|
<a-modal
|
:title="'修改记录'"
|
:width="700"
|
:visible="addUserdialog"
|
:confirmLoading="addUserDialogloading"
|
@ok="OkaddUserdialog"
|
@cancel="CanceladdUserdialog"
|
>
|
<a-form :form="addUserform" ref="addUserform">
|
<a-form-item label="id" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input disabled v-decorator="['id']" />
|
</a-form-item>
|
|
<a-form-item
|
v-if="currentdetail.cValueType !== 'bool'"
|
label="值"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-input
|
placeholder="请输入值"
|
v-decorator="['cValue', { rules: [{ required: true, message: '请输入值' }] }]"
|
/>
|
</a-form-item>
|
<a-form-item v-else label="值" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-radio-group
|
v-decorator="['cValue', { rules: [{ required: true, message: '请输入值' }] }]"
|
name="radioGroup"
|
>
|
<a-radio value="1">开启</a-radio>
|
<a-radio value="0">关闭</a-radio>
|
</a-radio-group>
|
</a-form-item>
|
<a-form-item label="描述" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input disabled placeholder="cDesc" v-decorator="['cDesc']" />
|
</a-form-item>
|
<a-form-item v-show="false" label="key" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input disabled placeholder="cKey" v-decorator="['cKey']" />
|
</a-form-item>
|
<a-form-item v-show="false" label="key" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input disabled placeholder="cValueType" v-decorator="['cValueType']" />
|
</a-form-item>
|
</a-form>
|
</a-modal>
|
</page-header-wrapper>
|
</template>
|
<script>
|
import { queryStockConfig, updateConfig } from '@/api/newshares'
|
import pick from 'lodash.pick'
|
export default {
|
name: 'Shares',
|
data() {
|
return {
|
columns: [
|
{
|
title: 'ID',
|
dataIndex: 'id',
|
align: 'center',
|
},
|
|
{
|
title: '值',
|
dataIndex: 'cValue',
|
align: 'center',
|
scopedSlots: { customRender: 'cValue' },
|
},
|
{
|
title: '描述',
|
dataIndex: 'cDesc',
|
align: 'center',
|
},
|
|
{
|
title: '操作',
|
key: 'action',
|
align: 'center',
|
scopedSlots: { customRender: 'action' },
|
},
|
],
|
// 表头
|
|
loading: false,
|
queryParam: {
|
cDesc: '',
|
},
|
datalist: [],
|
labelCol: {
|
xs: { span: 8 },
|
sm: { span: 8 },
|
md: { span: 8 },
|
},
|
wrapperCol: {
|
xs: { span: 14 },
|
sm: { span: 14 },
|
md: { span: 14 },
|
},
|
addUserform: this.$form.createForm(this),
|
addUserdialog: false,
|
addUserDialogloading: false,
|
fields: ['id', 'cValue', 'cDesc', 'cKey', 'status', 'cValueType'],
|
currentdetail: {},
|
}
|
},
|
created() {
|
this.getlist()
|
},
|
methods: {
|
geteditStock(val) {
|
this.currentdetail = val
|
this.addUserdialog = true
|
this.fields.forEach((v) => this.addUserform.getFieldDecorator(v))
|
this.addUserform.setFieldsValue(pick(val, this.fields))
|
},
|
CanceladdUserdialog() {
|
this.addUserdialog = false
|
const form = this.$refs.addUserform.form
|
form.resetFields()
|
},
|
OkaddUserdialog() {
|
const form = this.$refs.addUserform.form
|
form.validateFields((errors, values) => {
|
if (!errors) {
|
this.addUserDialogloading = true
|
updateConfig(values).then((res) => {
|
if (res.status == 0) {
|
this.addUserdialog = false
|
this.$message.success(res.msg)
|
form.resetFields()
|
this.getlist()
|
} else {
|
this.$message.error(res.msg)
|
}
|
this.addUserDialogloading = false
|
})
|
}
|
})
|
},
|
getqueryParam() {
|
this.queryParam = {
|
cDesc: '',
|
}
|
},
|
|
getlist() {
|
this.loading = true
|
queryStockConfig(this.queryParam).then((res) => {
|
this.datalist = res.data
|
this.loading = false
|
})
|
},
|
},
|
}
|
</script>
|