Selaa lähdekoodia

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
增加开放时间页面

1004749546@qq.com 4 vuotta sitten
vanhempi
commit
91932370f1

+ 10 - 0
src/config/router.config.js

@@ -180,6 +180,16 @@ export const asyncRouterMap = [{
           icon: 'profile'
           icon: 'profile'
           // permission: 'M_tenants_list'
           // permission: 'M_tenants_list'
         }
         }
+      },
+      {
+			  path: '/equipmentManage/openTimeSetting',
+			  name: 'openTimeSetting',
+			  component: () => import(/* webpackChunkName: "tenants" */ '@/views/equipmentManage/openTimeSetting/OpenTimeSetting.vue'),
+			  meta: {
+			    title: '投放时间设置',
+			    icon: 'profile'
+			    // permission: 'M_tenants_list'
+			  }
       }
       }
     ]
     ]
   },
   },

+ 209 - 0
src/views/equipmentManage/openTimeSetting/OpenTimeSetting.vue

@@ -0,0 +1,209 @@
+<template>
+  <a-card :bordered="false">
+    <div class="table-operator">
+      <a-button type="primary" icon="plus" @click="openModal" id="roleList-openModal">新增</a-button>
+    </div>
+
+    <s-table
+      ref="table"
+      size="default"
+      rowKey="id"
+      :columns="columns"
+      :data="loadData"
+      bordered>
+      <!-- 操作 -->
+      <span slot="action" slot-scope="text, record">
+        <a-icon type="edit" title="编辑" class="actionBtn icon-blues" @click="handleEdit(record)" />
+        <a-icon
+          type="delete"
+          title="删除"
+          class="actionBtn icon-red"
+          v-if="!record.isEnable"
+          @click="delect(record)" />
+      </span>
+    </s-table>
+    <roleModal :visible="showModal" :data="itemData" @refresh="refreshTable" @close="showModal = false"></roleModal>
+  </a-card>
+</template>
+
+<script>
+import {
+  STable,
+  VSelect
+} from '@/components'
+import roleModal from './roleModal.vue'
+import {
+  getPowerRoleList,
+  updateEnableStatus,
+  delectRolePower,
+  getMenuList
+} from '@/api/power-role.js'
+export default {
+  name: 'RoleList',
+  components: {
+    STable,
+    VSelect,
+    roleModal
+  },
+  data () {
+    return {
+      // 查询参数
+      queryParam: {
+        name: '',
+        isEnable: ''
+      },
+      showModal: false,
+      showMenuModal: false,
+      itemData: {}, // 编辑行数据
+      menuData: {},
+      // 表头
+      columns: [{
+        title: '序号',
+        dataIndex: 'no',
+        width: 60,
+        align: 'center'
+      },
+      {
+        title: '创建时间',
+        dataIndex: 'createDate',
+        width: 150,
+        align: 'center'
+      },
+      {
+        title: '角色名称',
+        dataIndex: 'name',
+        width: 200,
+        align: 'center'
+      },
+      {
+        title: '操作',
+        width: 150,
+        align: 'center',
+        scopedSlots: {
+          customRender: 'action'
+        }
+      }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        console.log(parameter, 'parameter')
+
+        return getPowerRoleList(Object.assign(parameter, this.queryParam)).then(res => {
+          const no = (res.data.pageNo - 1) * res.data.pageSize
+          for (let i = 0; i < res.data.list.length; i++) {
+            const _item = res.data.list[i]
+            _item.no = no + i + 1
+            _item.isEnable = _item.isEnable + '' === '1'
+          }
+          return res.data
+        })
+      },
+      optionAlertShow: false
+    }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      // vm.$refs.table.refresh()
+    })
+  },
+  methods: {
+    // 刷新列表
+    refreshTable () {
+      this.$refs.table.refresh(true)
+    },
+    // 重置
+    reset () {
+      this.queryParam.name = ''
+      this.queryParam.isEnable = ''
+      this.refreshTable()
+    },
+    // 新建
+    openModal () {
+      this.showModal = true
+      this.itemData = {}
+    },
+    // 打开分配权限弹窗
+    openMenuModal (row) {
+      this.getMenuList(row.id)
+    },
+    // 获取菜单树列表
+    getMenuList (id) {
+      const _this = this
+      getMenuList({
+        id: id
+      }).then(res => {
+        if (res.status == 200) {
+          _this.menuData = res.data
+          this.showMenuModal = true
+          console.log(res.data, 'this.itemData')
+        }
+      })
+    },
+
+    // 删除
+    delect (row) {
+      const _this = this
+      this.$confirm({
+        title: '警告',
+        centered: true,
+        content: '删除后无法恢复,确认删除?',
+        okText: '确定',
+        cancelText: '取消',
+        onOk () {
+          delectRolePower({
+            id: row.id
+          }).then(res => {
+            console.log(res, 'res1111')
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
+        }
+      })
+    },
+    handleEdit (row) {
+      console.log(row, 'row')
+      this.showModal = true
+      this.itemData = row
+    },
+    // 修改状态
+    changeFlagHandle (text, record) {
+      const _data = {
+        id: record.id,
+        flag: record.isEnable ? '1' : '0'
+      }
+      updateEnableStatus(_data).then(res => {
+        if (res.status + '' === '200') {
+          this.$message.success(res.message)
+        } else {
+          record.isEnable = !record.isEnable
+        }
+      })
+    }
+  }
+}
+</script>
+<style scoped>
+	.table-page-search-wrapper .ant-form-inline .ant-form-item {
+		margin-bottom: 0;
+	}
+
+	.action-button {
+		line-height: 40px;
+		white-space: nowrap;
+		padding: 5px 10px;
+		background-color: #1890ff;
+		border-radius: 4px;
+		color: #fff;
+		margin-right: 5px;
+	}
+
+	.red-text {
+		background-color: red;
+	}
+
+	.menu-text {
+		background-color: #f90;
+	}
+</style>

+ 177 - 0
src/views/equipmentManage/openTimeSetting/roleModal.vue

@@ -0,0 +1,177 @@
+<template>
+  <div>
+    <a-modal
+      class="modalBox"
+      :title="titleText"
+      v-model="isshow"
+      @cancle="cancel"
+      width="45%"
+      :centered="true">
+      <a-form :form="form" @submit="handleSubmit">
+        <!-- 用户名称 -->
+        <a-form-item label="角色名称" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
+          <a-input
+            placeholder="请输入角色名称(最多30个字符)"
+            allowClear
+            :maxLength="30"
+            id="roleModal-name"
+            v-decorator="['formData.name', {
+              initialValue: formData.name,getValueFromEvent: $filterEmpty,
+              rules: [{ required: true, message: '请输入角色名称(最多30个字符)!' },{pattern:'^[^<|>]{1,30}$',message:'请输入不含<或>的字符,最多30个字符'}] }]"
+          />
+        </a-form-item>
+
+        <!-- 状态 -->
+        <a-form-item label="状态" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
+          <a-radio-group
+            name="radioGroup"
+            id="roleModal-isEnable"
+            v-decorator="[
+              'formData.isEnable',
+              {
+                initialValue: formData.isEnable,
+                rules: [{ required: true, message: '请选择状态!' }] },
+            ]"
+          >
+            <a-radio :value="1">启用</a-radio>
+            <a-radio :value="0">禁用</a-radio>
+          </a-radio-group>
+        </a-form-item>
+
+        <a-form-item label="角色描述" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
+          <a-textarea
+            id="roleModal-remarks"
+            :maxLength="500"
+            v-decorator="[
+              'formData.remarks',
+              { initialValue: formData.remarks,getValueFromEvent: $filterEmpty,
+                rules: [] },
+            ]"
+            style="min-height: 60px;"
+            placeholder="请输入角色描述(最多500个字符)"
+            autosize />
+        </a-form-item>
+
+        <a-form-item :wrapper-col="{ span: 24, offset: 10 }">
+          <a-button type="primary" @click="handleSubmit()" id="roleModal-handleSubmit" :style="{ marginRight: '15px' }">
+            保存
+          </a-button>
+          <a-button :style="{ marginLeft: '15px' }" @click="handleCancel()" id="roleModal-handleCancel">
+            取消
+          </a-button>
+        </a-form-item>
+      </a-form>
+
+    </a-modal>
+  </div>
+</template>
+
+<script>
+import { STable, VSelect } from '@/components'
+import { saveRolePower } from '@/api/power-role.js'
+export default {
+  name: 'RoleModal',
+  components: {
+    STable, VSelect
+  },
+  props: {
+    visible: {
+      type: Boolean,
+      default: false
+    },
+    data: {
+      type: Object,
+      default: function () {
+        return {}
+      }
+    }
+  },
+  data () {
+    return {
+      titleText: '新增角色',
+      isshow: this.visible,
+      formLayout: 'horizontal',
+      form: this.$form.createForm(this, { name: 'roleModal' }),
+      formData: {
+        name: '',
+        isEnable: '', // 活动状态
+        remarks: ''
+      }
+
+    }
+  },
+  methods: {
+    cancel (e) {
+      this.clear()
+      this.$emit('close')
+    },
+
+    // 保存提交
+    handleSubmit () {
+      const _this = this
+      this.form.validateFields((err, values) => {
+        if (!err) {
+          console.log(values.formData, ' formData.type222222222')
+          saveRolePower(Object.assign(this.formData, values.formData)).then(res => {
+            console.log(res, 'res--save')
+            if (res.status + '' === '200') {
+              this.$message.success(res.message ? res.message : '保存成功')
+              this.$emit('refresh')
+              setTimeout(function () {
+                _this.cancel()
+              }, 300)
+            } else {
+              // this.$message.error(res.message)
+            }
+          })
+        }
+      })
+    },
+    // 取消
+    handleCancel () {
+      this.cancel()
+    },
+    clear () {
+      this.form.resetFields()
+      delete this.formData.id
+      this.formData.name = ''
+      this.formData.isEnable = ''
+      this.formData.remarks = ''
+    }
+
+  },
+  mounted () {
+  },
+  beforeCreate () {
+    this.form = this.$form.createForm(this, { name: 'roleModal' })
+  },
+  watch: {
+    visible (newValue, oldValue) {
+      this.isshow = newValue
+    },
+    isshow (newValue, oldValue) {
+      if (newValue) {
+        if (this.data.id) { // 编辑
+          this.titleText = '编辑角色'
+          this.formData = Object.assign({}, this.data)
+          delete this.formData.no
+          this.formData.isEnable = Number(this.formData.isEnable)
+          console.log(this.formData, 'this.formData')
+        } else {
+          this.titleText = '新增角色'
+        }
+      } else {
+        this.cancel()
+      }
+    }
+  }
+}
+</script>
+
+<style >
+  .modalBox{
+  }
+  .ant-modal-footer {
+    display: none;
+  }
+</style>