<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-isLocked="{ row }">
        <v-chip v-if="row.isLocked === true" color="red" dark>是</v-chip>
        <v-chip v-else color="green" dark>否</v-chip>
      </template>
      <template v-slot:col-isFrozen="{ row }">
        <v-chip v-if="row.isFrozen === true" color="red" dark>是</v-chip>
        <v-chip v-else color="green" dark>否</v-chip>
      </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.materialGroup

export default {
  name: page.name,
  mixins: [mixins.list],
  components: { SavePage },
  data() {
    return {
      list: {
        title: page.title,
        cols,
        action: api.query,
        model: {
          /** 编码 */
          nId: '',
          /** 名称 */
          name: '',
          /** 描述 */
          description: '',
          /** 物料组父级 */
          materialGroupParents: ''
        },
        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>
