<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="name">
          <el-input v-model="list.model.name" clearable />
        </el-form-item>
        <el-form-item label="文件类型：" prop="type">
          <el-input v-model="list.model.type" clearable />
        </el-form-item>
        <el-form-item label="文件大小：" prop="payloadSize">
          <el-input v-model="list.model.payloadSize" clearable />
        </el-form-item>
        <el-form-item label="创建人：" prop="createdUser">
          <el-input v-model="list.model.createdUser" clearable />
        </el-form-item>
        <el-form-item label="最后更新人：" prop="lastUpdatedUser">
          <el-input v-model="list.model.lastUpdatedUser" clearable />
        </el-form-item>
        <el-form-item label="文件夹Id：" prop="folder_Id">
          <el-input v-model="list.model.folder_Id" 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.file

export default {
  name: page.name,
  mixins: [mixins.list],
  components: { SavePage },
  data() {
    return {
      list: {
        title: page.title,
        cols,
        action: api.query,
        model: {
          /** 是否删除 */
          isDeleted: '',
          /** 是否锁定 */
          isLocked: '',
          /** 是否冻结 */
          isFrozen: '',
          /** 文件名 */
          name: '',
          /** 文件类型 */
          type: '',
          /** 文件大小 */
          payloadSize: '',
          /** 创建人 */
          createdUser: '',
          /** 最后更新人 */
          lastUpdatedUser: '',
          /** 文件夹Id */
          folder_Id: ''
        },
        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>
