<template>
  <nm-container>
    <nm-list ref="list" v-bind="list">
      <!--查询条件-->
      <template v-slot:querybar> </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" :bomId="billOfMaterialNId" />
    <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.billOfMaterialProperty

export default {
  name: page.name,
  mixins: [mixins.list],
  components: { SavePage },
  data() {
    return {
      billOfMaterialNId: '',
      list: {
        title: page.title,
        cols,
        action: this.query,
        model: {
          /** 编码 */
          nId: '',
          /** 属性 */
          proppertyType: '',
          /** 属性值 */
          propertyValue: '',
          /** 物料清单 */
          billOfMaterial: this.billOfMaterialNId,
          /** 是否锁定 */
          isLocked: '',
          /** 是否冻结 */
          isFrozen: ''
        },
        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: {
    query() {
      return new Promise(resolve => {
        api.query({ BillOfMaterial: this.billOfMaterialNId }).then(datas => {
          let options = datas
          resolve(options)
        })
      })
    }
  },
  watch: {
    billOfMaterialNId: function() {
      this.$refs.list.query()
    }
  }
}
</script>
