<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-form
          :inline="true"
          class="demo-form-inline"
          label-position="right"
          label-width="80px"
          label-suffix=":"
        >
          <el-form-item label="模糊查找">
            <el-input
              v-model="query.blurry"
              clearable
              placeholder="模糊查询"
              class="filter-item"
              @keyup.enter.native="crud.toQuery"
            />
          </el-form-item>
          <rrOperation :crud="crud"/>
        </el-form>
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog
        :close-on-click-modal="false"
        :before-close="crud.cancelCU"
        :visible.sync="crud.status.cu > 0"
        :title="crud.status.title"
        width="820px"
      >
        <el-form
          ref="form"
          style="border: 1px solid #cfe0df;margin-top: 10px;padding-top: 10px;"
          :inline="true"
          :model="form"
          :rules="rules"
          size="mini"
          label-width="135px"
          label-suffix=":"
        >
          <el-form-item label="客户编码">
            <el-input :disabled="crud.status.edit > 0" v-model="form.cust_code" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="客户名称 ">
            <el-input v-model="form.cust_name" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="法人代表">
            <el-input v-model="form.jurid_name" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="税务登记号">
            <el-input v-model="form.tax_no" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="工商注册号">
            <el-input v-model="form.register_no" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="经营许可证号">
            <el-input v-model="form.manage_lice_no" style="width: 240px;" />
          </el-form-item>
          <el-form-item v-if="false" label="营业执照">
            <el-input v-model="form.busi_char_name" style="width: 240px;" />
          </el-form-item>
<!--          <el-form-item label="行政区划">-->
<!--            <el-input v-model="form.area_id" style="width: 240px;" />-->
<!--          </el-form-item>-->
          <el-form-item label="邮政编码">
            <el-input v-model="form.zip_code" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="公司电话">
            <el-input v-model="form.corp_tele_no" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="公司地址">
            <el-input v-model="form.corp_address" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="是否启用">
            <el-radio-group v-model="form.is_used" style="width: 240px">
              <el-radio :label="true">是</el-radio>
              <el-radio :label="false">否</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="外部标识">
            <el-input v-model="form.ext_id" style="width: 240px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remark" :rows="3" type="textarea" style="width: 240px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="cust_code" label="客户编码" :min-width="flexWidth('cust_code',crud.data,'客户编码')" />
        <el-table-column prop="cust_name" label="客户名称 " :min-width="flexWidth('cust_name',crud.data,'客户名称 ')" />
        <el-table-column prop="jurid_name" label="法人代表" :min-width="flexWidth('jurid_name',crud.data,'法人代表')" />
        <el-table-column prop="tax_no" label="税务登记号" :min-width="flexWidth('tax_no',crud.data,'税务登记号')" />
        <el-table-column prop="register_no" label="工商注册号" :min-width="flexWidth('register_no',crud.data,'工商注册号')" />
        <el-table-column prop="manage_lice_no" label="经营许可证号" :min-width="flexWidth('manage_lice_no',crud.data,'经营许可证号')" />
<!--        <el-table-column prop="area_id" label="行政区划" :min-width="flexWidth('area_id',crud.data,'行政区划')" />-->
        <el-table-column prop="zip_code" label="邮政编码" :min-width="flexWidth('zip_code',crud.data,'邮政编码')" />
        <el-table-column prop="corp_tele_no" label="公司电话" :min-width="flexWidth('corp_tele_no',crud.data,'公司电话')" />
        <el-table-column prop="corp_address" label="公司地址" :min-width="flexWidth('corp_address',crud.data,'公司地址')" />
        <el-table-column prop="create_name" label="创建人姓名" :min-width="flexWidth('create_name',crud.data,'创建人姓名')" />
        <el-table-column prop="create_time" label="创建时间" :min-width="flexWidth('create_time',crud.data,'创建时间')" />
        <el-table-column prop="update_time" label="修改时间" :min-width="flexWidth('update_time',crud.data,'修改时间')" />
        <el-table-column prop="is_used_time" label="启用时间" :min-width="flexWidth('is_used_time',crud.data,'启用时间')" />
        <el-table-column prop="is_used" label="是否启用" :min-width="flexWidth('is_used',crud.data,'是否启用')" />
<!--        <el-table-column prop="is_delete" label="是否删除" :min-width="flexWidth('is_delete',crud.data,'是否删除')" />-->
        <el-table-column prop="ext_id" label="外部标识" :min-width="flexWidth('ext_id',crud.data,'外部标识')" />
        <el-table-column prop="remark" label="备注" :min-width="flexWidth('remark',crud.data,'备注')" />
        <el-table-column prop="update_id" label="修改人" :min-width="flexWidth('update_id',crud.data,'修改人')" />
        <el-table-column prop="update_name" label="修改人姓名" :min-width="flexWidth('update_name',crud.data,'修改人姓名')" />
        <el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudMdCsCustomerbase from './mdCsCustomerbase'
import CRUD, {crud, form, header, presenter} from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = {
  cust_id: null,
  cust_code: null,
  cust_name: null,
  jurid_name: null,
  tax_no: null,
  register_no: null,
  manage_lice_no: null,
  busi_char_name: null,
  area_id: null,
  zip_code: null,
  corp_tele_no: null,
  corp_address: null,
  create_id: null,
  create_name: null,
  create_time: null,
  update_time: null,
  is_used_time: null,
  is_used: false,
  is_delete: null,
  ext_id: null,
  remark: null,
  class_id: null,
  update_id: null,
  update_name: null
}
export default {
  name: 'Customerbase',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '客户信息管理',
      url: 'api/mdCsCustomerbase',
      idField: 'cust_id',
      sort: 'cust_id,desc',
      crudMethod: { ...crudMdCsCustomerbase },
      optShow: {
        add: true,
        edit: true,
        del: true,
        download: false,
        reset: true
      }
    })
  },
  data() {
    return {
      permission: {
      },
      rules: {
      }
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
