|
@@ -0,0 +1,247 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="button-container" v-if="model != 'detail'">
|
|
|
+ <el-button type="primary" size="small" :loading="btnLoading" @click="submitForm">提 交</el-button>
|
|
|
+ <el-button size="small" @click="init">重 置</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="form_center" :class="model == 'detail'?'pointer_events_none':''">
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="100px" label-position="left">
|
|
|
+ <el-form-item label="租户名称" prop="tenant">
|
|
|
+ <el-input v-model="form.name" placeholder="请输入租户名称" :readonly="true"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="可使用人员数量" prop="number">
|
|
|
+ <el-input-number v-model="form.number" size="small" controls-position="right" :min="0"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="状态" prop="state">
|
|
|
+ <el-switch
|
|
|
+ style="display: block"
|
|
|
+ v-model="scope.row.state"
|
|
|
+ @change="(val)=>changeState(scope.row,val)"
|
|
|
+ active-color="#13ce66"
|
|
|
+ inactive-color="red"
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="0"
|
|
|
+ active-text="启用"
|
|
|
+ inactive-text="禁用">
|
|
|
+ </el-switch>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="类型" prop="type">
|
|
|
+ <el-select v-model="form.type" placeholder="请选择企业类型">
|
|
|
+ <el-option v-for="item in tenantType" :key="item.dictChildValue" :label="item.dictChildLabel" :value="Number(item.dictChildValue)"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="描述" prop="describe">
|
|
|
+ <el-input v-model="form.describe" placeholder="请输入描述" type="textarea" maxlength="100" show-word-limit></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <div style="border:1px solid white;padding:10px;margin:10px 0;border-radius:8px;height:300px">
|
|
|
+ <vipTypeTable :tableData="tableData"></vipTypeTable>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+const currentForm = {
|
|
|
+ tenantId:null,
|
|
|
+ name:null,
|
|
|
+ describe:null,
|
|
|
+ number:null,
|
|
|
+ state:1,
|
|
|
+ type:0,
|
|
|
+ vipTypes:[],
|
|
|
+}
|
|
|
+import commonData from '../mixins/commonData'
|
|
|
+import vipTypeTable from '@/views/backStageManage/paymentCode/paymentCode/components/table/vipType.vue'
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ vipTypeTable
|
|
|
+ },
|
|
|
+ mixins:[commonData],
|
|
|
+ props: {
|
|
|
+ id:null,
|
|
|
+ model:{
|
|
|
+ type:String,
|
|
|
+ default:"add"
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ btnLoading: false,
|
|
|
+ // 表单参数
|
|
|
+ form: {},
|
|
|
+ rules: {},
|
|
|
+ tableData:[]
|
|
|
+ };
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ id(){
|
|
|
+ if(this.$route.path != '/administrator/editTenant'){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ userinfo() {
|
|
|
+ return this.$store.state.admin.userinfo
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {},
|
|
|
+ mounted() {
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //初始化当前页面
|
|
|
+ async init(){
|
|
|
+ if(this.model == 'add'){
|
|
|
+ this.resetForm()
|
|
|
+ }else if(this.model == 'edit' || this.model == 'detail'){
|
|
|
+ await this.getById()
|
|
|
+ }
|
|
|
+ if(this.model == 'detail'){
|
|
|
+ this.tableData = this.form.vipTypes || []
|
|
|
+ }else{
|
|
|
+ this.getVipType()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //查询数据并校验
|
|
|
+ async getById(){
|
|
|
+ if(!this.id){
|
|
|
+ this.$message.error('编辑缺少参数')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var params = {
|
|
|
+ ids: [this.id],
|
|
|
+ };
|
|
|
+ await this.$api.queryQiaoBiTenant(params).then(response=>{
|
|
|
+ if(response.code == 200){
|
|
|
+ var data = response.data.records
|
|
|
+ if(data && data.length>0){
|
|
|
+ this.form = data[0]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch(error=>{
|
|
|
+ this.resetForm()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //重置表单
|
|
|
+ resetForm(){
|
|
|
+ this.form = Object.assign({}, currentForm)
|
|
|
+ this.$refs['form'].resetFields();
|
|
|
+ },
|
|
|
+ /** 提交按钮 */
|
|
|
+ submitForm: function() {
|
|
|
+ this.$refs['form'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.form.vipTypes = this.tableData.map(item=>{
|
|
|
+ return {
|
|
|
+ vipTypeId:item.id,
|
|
|
+ vipTypeNum:item.vipTypeNum,
|
|
|
+ vipTypeName:item.vipTypeName
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.form.tenantId = this.form.id
|
|
|
+ this.btnLoading = true
|
|
|
+ var a = '添加'
|
|
|
+ var api = 'addPaymentCode'
|
|
|
+ if(this.model == "edit"){
|
|
|
+ a = '编辑'
|
|
|
+ api = 'updateTenantVip'
|
|
|
+ }
|
|
|
+ this.$api[api](this.form).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.btnLoading = false
|
|
|
+ this.$message.success( a + '成功');
|
|
|
+ this.finish()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ this.$message.error(a + '失败')
|
|
|
+ this.btnLoading = false
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ finish(){
|
|
|
+ if(this.model == 'add'){
|
|
|
+ this.init()
|
|
|
+ }else{
|
|
|
+ this.$store.commit('removeHistoryPath',this.$route.path);
|
|
|
+ this.$store.commit('removeHistory',this.$route.path);
|
|
|
+ this.$router.push(
|
|
|
+ {
|
|
|
+ path:'/administrator/tenant'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //获取会员类型
|
|
|
+ getVipType(){
|
|
|
+ var params = {}
|
|
|
+ this.$api.getVipList(params).then(response=>{
|
|
|
+ if(response.code == 200){
|
|
|
+ var data = response.data.records
|
|
|
+ if(!data || data.length == 0){
|
|
|
+ this.tableData = []
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.model == 'add'){
|
|
|
+ this.tableData = data.map(item=>{
|
|
|
+ item.vipTypeNum = 0
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var vipTypes = this.form.vipTypes
|
|
|
+ if(!vipTypes || vipTypes.length == 0){
|
|
|
+ this.tableData = data.map(item=>{
|
|
|
+ item.vipTypeNum = 0
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for(var i = 0;i<data.length;i++){
|
|
|
+ var item = data[i]
|
|
|
+ var obj = vipTypes.find(vip=>{
|
|
|
+ return vip.vipTypeId == item.id
|
|
|
+ })
|
|
|
+ if(obj){
|
|
|
+ this.$set(item,'vipTypeNum',obj.vipTypeNum || 0)
|
|
|
+ }else{
|
|
|
+ this.$set(item,'vipTypeNum', 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.tableData = data
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss">
|
|
|
+.form_center {
|
|
|
+ width: 800px;
|
|
|
+ margin: 30px auto;
|
|
|
+}
|
|
|
+
|
|
|
+.button-container {
|
|
|
+ max-width: 1200px;
|
|
|
+ display: flex;
|
|
|
+ justify-content:flex-end;
|
|
|
+ margin: 10px auto;
|
|
|
+ position:sticky;
|
|
|
+ top:10px,
|
|
|
+}
|
|
|
+.form_item_title{
|
|
|
+ color: black;
|
|
|
+ font-weight: bold;
|
|
|
+ font-size: 14px;
|
|
|
+ padding: 5px 0;
|
|
|
+ border-bottom: 1px solid white;
|
|
|
+}
|
|
|
+</style>
|