<template>
  <nm-container>
    <nm-list ref="list" v-bind="list">
      <!--查询条件-->
      <template v-slot:querybar>
        <el-form-item label="是否删除：" prop="isDeleted">
          <el-input v-model="list.model.isDeleted" clearable />
        </el-form-item>
        <el-form-item label="是否锁定：" prop="isLocked">
          <el-input v-model="list.model.isLocked" clearable />
        </el-form-item>
        <el-form-item label="是否冻结：" prop="isFrozen">
          <el-input v-model="list.model.isFrozen" clearable />
        </el-form-item>
        <el-form-item label="原值：" prop="k0Multiplier">
          <el-input v-model="list.model.k0Multiplier" clearable />
        </el-form-item>
        <el-form-item label="附加数：" prop="addend">
          <el-input v-model="list.model.addend" clearable />
        </el-form-item>
        <el-form-item label="换算值：" prop="k1Multiplier">
          <el-input v-model="list.model.k1Multiplier" clearable />
        </el-form-item>
        <el-form-item label="指数幂：" prop="exponent">
          <el-input v-model="list.model.exponent" clearable />
        </el-form-item>
        <el-form-item label="是否隐藏：" prop="isHidden">
          <el-input v-model="list.model.isHidden" clearable />
        </el-form-item>
        <el-form-item label="是否系统定义：" prop="isSystemDefined">
          <el-input v-model="list.model.isSystemDefined" clearable />
        </el-form-item>
        <el-form-item label="换算后单位：" prop="targetUoMId">
          <el-input v-model="list.model.targetUoMId" clearable />
        </el-form-item>
        <el-form-item label="换算前单位：" prop="sourceUoMId">
          <el-input v-model="list.model.sourceUoMId" clearable />
        </el-form-item>
      </template>

      <!--按钮-->
      <template v-slot:querybar-buttons>
        <nm-button v-bind="buttons.add" @click="add" />
      </template>

      <!--自定义列-->
      <!-- <template v-slot:col-name="{row}">
        <nm-button :text="row.name" type="text" />
      </template> -->

      <!--操作列-->
      <template v-slot:col-operation="{ row }">
        <nm-button v-bind="buttons.edit" @click="edit(row)" />
        <nm-button-delete v-bind="buttons.del" :id="row.id" :action="removeAction" @success="refresh" />
      </template>
    </nm-list>

    <save-page :id="curr.id" :visible.sync="dialog.save" @success="refresh" />
    <form-create v-model="formModel" :rule="rule" :option="option" v-show="this.index_LoadMode"></form-create>
  </nm-container>
</template>
<script>
import { mixins } from 'xmanager-ui'
import page from './page'
import cols from './cols'
import SavePage from '../components/save'

const api = $api.reference.uoMFactor

export default {
  name: page.name,
  mixins: [mixins.list],
  components: { SavePage },
  data() {
    return {
      list: {
        title: page.title,
        cols,
        action: api.query,
        model: {
          /** 是否删除 */
          isDeleted: '',
          /** 是否锁定 */
          isLocked: '',
          /** 是否冻结 */
          isFrozen: '',
          /** 原值 */
          k0Multiplier: '',
          /** 附加数 */
          addend: '',
          /** 换算值 */
          k1Multiplier: '',
          /** 指数幂 */
          exponent: '',
          /** 是否隐藏 */
          isHidden: '',
          /** 是否系统定义 */
          isSystemDefined: '',
          /** 换算后单位 */
          targetUoMId: '',
          /** 换算前单位 */
          sourceUoMId: ''
        },
        isVuetify: true,
        isSearch: true,
        isAdd: true,
        isExport: false,
        showSelect: true,
        singleSelect: false,
      },
      removeAction: api.remove,
      buttons: page.buttons,
      /**Code Manage 开始 */
      list_LoadMode: false,
      index_LoadMode: false,
      save_LoadMode: false,
      formModel: {},
      rule: [],
      option: {
        submitBtn: false,
      },
    }
  },
  // methods: {
  //   //默认树形点击事件
  //   clickTree(tree) {
  //     this.formModel.el('tableList')._props.model.name = tree.label
  //     this.formModel.exec('tableList', 'action')
  //     this.refresh()
  //   },
  //   //默认table刷新页面
  //   refresh() {
  //     this.formModel.el('tableList').refresh()
  //   },
  //   getMenu() {
  //     menuapi.query({ routeName: page.name }).then((data) => {
  //       if (data.rows) {
  //         let row = data.rows[0]
  //         this.index_LoadMode = row.index_LoadMode
  //         this.setRule(row.pageManage_Index.pageJson)
  //       }
  //     })
  //   },
  //   setRule(rule) {
  //     if (this.index_LoadMode) {
  //       this.rule = JSON.parse(rule)
  //       this.list_LoadMode = false
  //     } else {
  //       this.list_LoadMode = true
  //     }
  //   },
  // },
  // created() {
  //   this.getMenu()
  // },
  /**Code Manage 结束 */
}
</script>
