<template>
  <nm-container>
    <nm-list ref="list" v-bind="list">
      <!--查询条件-->
      <template v-slot:querybar> </template>

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

      <!--自定义列-->
      <template v-slot:col-isHidden="{ row }">
        <nm-label type="primary" v-if="row.isHidden == true">隐藏</nm-label>
        <nm-label type="danger" v-else-if="row.isHidden == false">不隐藏</nm-label>
      </template>
      <template v-slot:col-isSystemDefined="{ row }">
        <nm-label type="primary" v-if="row.isSystemDefined == 'true'">定义</nm-label>
        <nm-label type="danger" v-else-if="row.isSystemDefined == 'false'">无定义</nm-label>
      </template>
      <template v-slot:col-isLocked="{ row }">
        <nm-label type="primary" v-if="row.isLocked == false">未锁定</nm-label>
        <nm-label type="danger" v-else-if="row.isLocked == true">锁定</nm-label>
      </template>
      <template v-slot:col-isFrozen="{ row }">
        <nm-label type="primary" v-if="row.isFrozen == false">未冻结</nm-label>
        <nm-label type="danger" v-else-if="row.isFrozen == true">冻结</nm-label>
      </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.materialApp.materialUoM

export default {
  name: page.name,
  mixins: [mixins.list],
  components: { SavePage },
  data() {
    return {
      list: {
        title: page.title,
        cols,
        action: api.query,
        model: {
          /** NId连接id */
          nId: '',
          /** 是否隐藏 */
          isHiddens: '',
          /** 计量单位 */
          uoMDimension: '',
          /** 是否定义系统 */
          isSystemDefined: '',
          /** 描述 */
          description: '',
          /** 名称 */
          name: '',
          /** 导航属性 */
          uoMBase: ''
        },
        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
      }
    }
  }
}
</script>
