<template> 
 | 
  <GlobalWindow 
 | 
      class="handle-table-dialog" 
 | 
      :title="title" 
 | 
      width="60%" 
 | 
      :visible.sync="visible" 
 | 
      :confirm-working="isWorking" 
 | 
      @confirm="confirm" 
 | 
  > 
 | 
    <p class="tip" v-if="form.parent != null && form.id == null">为 <em>{{parentName}}</em> 新建下级分类</p> 
 | 
    <el-form :model="form" ref="form" :rules="rules"> 
 | 
      <el-form-item label="父级分类" prop="parentId" > 
 | 
        <el-select v-model="form.parentId"  placeholder="选择父级分类" clearable> 
 | 
          <el-option v-for="item in parentList" :key="item.id" :value="item.id" :label="item.name"/> 
 | 
        </el-select> 
 | 
      </el-form-item> 
 | 
      <el-form-item label="分类名称" prop="name" required> 
 | 
        <el-input v-model="form.name" placeholder="请输入分类名称" v-trim maxlength="50"/> 
 | 
      </el-form-item> 
 | 
      <el-form-item label="排序码(升序)" prop="sortnum"> 
 | 
        <el-input v-model="form.sortnum"  type="number" placeholder="请输入排序码(升序)" v-trim maxlength="200"/> 
 | 
      </el-form-item> 
 | 
      <el-form-item label="备注" prop="remark"> 
 | 
        <el-input type="textarea" v-model="form.remark" placeholder="请输入备注" v-trim :rows="3" maxlength="500"/> 
 | 
      </el-form-item> 
 | 
    </el-form> 
 | 
  </GlobalWindow> 
 | 
</template> 
 | 
  
 | 
<script> 
 | 
import BaseOpera from '@/components/base/BaseOpera' 
 | 
import GlobalWindow from '@/components/common/GlobalWindow' 
 | 
import icons from '@/utils/icons' 
 | 
import { numRuleNotRequired} from '@/utils/form' 
 | 
export default { 
 | 
  name: 'OperaCategoryWindow', 
 | 
  extends: BaseOpera, 
 | 
  components: {  GlobalWindow }, 
 | 
  data () { 
 | 
    return { 
 | 
      icons, 
 | 
      // 上级菜单名称 
 | 
      parentName: '', 
 | 
      // 需排除选择的菜单ID 
 | 
      parentList: [], 
 | 
      // 表单数据 
 | 
      form: { 
 | 
        id: null, 
 | 
        parentId: null, 
 | 
        name: '', 
 | 
        type: '0', 
 | 
        sortnum: null, 
 | 
        remark: '' 
 | 
      }, 
 | 
      // 验证规则 
 | 
      rules: { 
 | 
        name: [ 
 | 
          { required: true, message: '请输入分类名称' } 
 | 
        ], 
 | 
        sortnum: [ 
 | 
          { required: false,validator: numRuleNotRequired } 
 | 
        ] 
 | 
      } 
 | 
    } 
 | 
  }, 
 | 
  methods: { 
 | 
    /** 
 | 
     * @title: 窗口标题 
 | 
     * @target: 编辑的菜单对象 
 | 
     * @parent: 新建时的上级菜单 
 | 
     */ 
 | 
    open (title, target, parent,list) { 
 | 
      this.title = title 
 | 
      this.visible = true 
 | 
      // 新建,menu为空时表示新建菜单 
 | 
      this.parentList = list || [] 
 | 
      if (target == null) { 
 | 
        this.$nextTick(() => { 
 | 
          this.$refs.form.resetFields() 
 | 
          this.form.id = null 
 | 
          this.form.parentId = parent == null ? null : parent.id 
 | 
          this.parentName = parent == null ? null : parent.name 
 | 
        }) 
 | 
        return 
 | 
      } 
 | 
      // 编辑 
 | 
      this.$nextTick(() => { 
 | 
        for (const key in this.form) { 
 | 
          this.form[key] = target[key] 
 | 
        } 
 | 
      }) 
 | 
    } 
 | 
  }, 
 | 
  created () { 
 | 
    this.config({ 
 | 
      api: '/business/category' 
 | 
    }) 
 | 
  } 
 | 
} 
 | 
</script> 
 | 
  
 | 
<style scoped lang="scss"> 
 | 
@import "@/assets/style/variables"; 
 | 
$icon-background-color: $primary-color; 
 | 
.global-window { 
 | 
  .tip { 
 | 
    margin-bottom: 12px; 
 | 
    em { 
 | 
      font-style: normal; 
 | 
      color: $primary-color; 
 | 
      font-weight: bold; 
 | 
    } 
 | 
  } 
 | 
  // 图标 
 | 
  /deep/ .form-item-icon { 
 | 
    .el-form-item__content { 
 | 
      height: 193px; 
 | 
      overflow-y: auto; 
 | 
    } 
 | 
    .el-radio-group { 
 | 
      background: $icon-background-color; 
 | 
      padding: 4px; 
 | 
      .el-radio { 
 | 
        margin-right: 0; 
 | 
        color: #fff; 
 | 
        padding: 6px; 
 | 
        &.is-checked { 
 | 
          background: $icon-background-color - 30; 
 | 
          border-radius: 10px; 
 | 
        } 
 | 
        .el-radio__input.is-checked + .el-radio__label { 
 | 
          color: #fff; 
 | 
        } 
 | 
      } 
 | 
      .el-radio__input { 
 | 
        display: none; 
 | 
      } 
 | 
      .el-radio__label { 
 | 
        padding-left: 0; 
 | 
        // element-ui图标 
 | 
        i { 
 | 
          font-size: 30px; 
 | 
        } 
 | 
        // 自定义图标 
 | 
        [class^="eva-icon-"], [class*=" eva-icon-"] { 
 | 
          width: 30px; 
 | 
          height: 30px; 
 | 
          background-size: 25px; 
 | 
          vertical-align: bottom; 
 | 
        } 
 | 
      } 
 | 
      .el-radio--small { 
 | 
        height: auto; 
 | 
        padding: 8px; 
 | 
        margin-left: 0; 
 | 
      } 
 | 
    } 
 | 
  } 
 | 
} 
 | 
</style> 
 |