<!-- 供应商维护 -->
<template>
  <div class="container">
    <Form  :label-width="80" inline>
      <FormItem label="关键词"> 
        <Poptip trigger="focus"  width="250" placement="bottom">
            <div slot="content">
              <ul style="" class="commons-select-search">
                <li :key="i.id" v-for="i in supplierList" @click="params.keyword = i.supplierName">
                  {{i.supplierName}}
                </li>
              </ul>
            </div>
            <Input style="width:150px" v-model="params.keyword" @on-change="getSupplierSelectList" placeholder="请输入用途关键词"></Input>
        </Poptip>
        
      </FormItem>
      <Form-item label="按产品查看">
					<Select
						v-model="params.PurposeIndex"
						style="width: 150px"
						@on-change="selectPurposeFn"
						filterable
					>
						<div slot="empty">无匹配数据</div>
						<Option value="">全部</Option>
						<Option
							v-for="(i, index) in selectPurposeList"
							:value="i"
							:key="index"
							>{{ i }}</Option
						>
					</Select>
				</Form-item>
      <FormItem label="按账期查看">
        <Select v-model="params.accountDate" style="width:150px" >
            <div slot="empty">无匹配数据</div>
            <Option  value="">全部</Option>
            <Option v-for="(i,index) in accountDateList" :value="i.value" :key="index">
              {{ i.label }}
            </Option>
        </Select>
      </FormItem>
      <FormItem label="按采购周期">
        <Select v-model="params.type" style="width:150px">
            <div slot="empty">无匹配数据</div>
            <Option  value="">全部</Option>
            <Option v-for="(i,index) in safetyWarnDayList" :value="i.value" :key="index">
              {{ i.label }}
            </Option>
        </Select>
      </FormItem>
      <Button type="primary" @click="getStatisticsClassify();changePage(1)">查询</Button>
      <div style="float:right">
        <Button type="primary" style="margin-right:10px" @click="eventHandle('account')">收款账号维护</Button>
        <Button type="primary" style="margin-right:10px" @click="eventHandle('priceHandle')">价格维护</Button>
        <Button type="primary" @click="eventHandle('add')">添加</Button>
      </div>
    </Form>
    <div class="tabs-warp">
      <div 
        @click="params.type = i.value;changePage(1);" 
        :class="params.type == i.value ? 'active' : ''" 
        v-for="i in statisticsClassifyData" 
        :key="i.value">
        {{i.label}}
      </div>
    </div>
    <my-table :calcHeight="110" :data="data" :columns="columns" :table-page="params" @event-handle="eventHandle" @on-change="changePage"></my-table>
    <my-modal-form
      v-model="show"
      :title="title"
      :isMaterial="true"
      width="800px"
      :config="formType === 'add'? formConfig: formType === 'edit'? editFormConfig : showFormConfig"
      :rule-validate="ruleValidate"
      :data="formData"
      :type="formType"
      @confirm="cfm">
    </my-modal-form>
    <provider-account-form v-model="accountShow"></provider-account-form>
    <Modal
      v-model="accountDateRemarkModal"
      title="采购周期"
      >
      <Table :data="accountDateRemarkModalData" :columns="accountDateRemarkModalcolumns"></Table>
    </Modal>
  </div>
</template>

<script>
import { GetUserPageList } from '@/api/user'
import MyTable from '_c/my-table/my-table2'
import MyModalForm from '_c/my-modal-form/my-modal-form'
import ProviderAccountForm from './provider-account-form'
import axios from 'axios'
import dun from '@/assets/images/dun.png'
import renderListimgs from '_c/my-table/renderListimgs'

export default {
  name: 'provider_maintenance',
  components: {
    MyTable,
    MyModalForm,
    ProviderAccountForm,
    renderListimgs
  },
  data () {
    const v = this
    return {
      dun:dun,
      technologyTypeList:['直喷','热转','打纸','墨水','其他','全部'],
      statisticsClassifyData:[],
      title: '',
      show: false,
      accountShow: false,
      supplierList:[],
      data: [],
      deleteId: '',
      formType: '',
      formData: {
        certificate:null,
        businessLicense:null,
      },
      ruleValidate: {
        
        // categoryCode: [
        //   { required: true, message: '物料类型不能为空', trigger: 'blur' }
        // ],
        // name: [
        //   { required: true, message: '供应商名称不能为空', trigger: 'blur' }
        // ],
        // accountDate: [
        //   { required: true, message: '账期不能为空', trigger: 'blur' }
        // ],

        
      },
      formConfig: [
        {
          type: 'input',
          label: '供应商代码',
          key: 'code',
          disabled: true,
          placeholder: '系统自动生成',
          span: 12
        },
        // {
        //   type: 'selectSearch',
        //   label: '绑定用户',
        //   key: 'bingdUserID',
        //   list: [],
        //   placeholder: '请输入绑定用户',
        //   span: 12
        // },
        {
          type: 'input',
          label: '登录账户',
          key: 'bindUserAccount',
          placeholder: '请输入登录账户',
          span: 12
        },
        {
          type: 'selectSearch',
          label: '物料类型',
          key: 'materialClassifyId',
          list: [],
          placeholder: '请选择物料类型',
          span: 12
        },
        {
          type: 'upload',
          label: '供应商名称',
          text: '上传营业执照',
          key: 'name'
        },
        {
          type: 'input',
          label: '账期',
          key: 'accountDate',
          placeholder: '请输入账期',
          span: 12
        },
        
        {
          type: 'input',
          label: '账期说明',
          key: 'accountDateRemark',
          placeholder: '请输入账期说明',
          span: 12
        },
        {
          type: 'upload-flie',
          label: '营业执照',
          text: '上传营业执照',
          key: 'businessLicense',
        },
        {
          type: 'upload-flie',
          label: 'ca65',
          text: '加州65号法令合规测试证书',
          key: 'certificate'
        },
        {
          type: 'input',
          comType: 'textarea',
          label: '备注',
          key: 'remark',
          placeholder: '请输入仓库说明'
        },
        {
          type: 'tabs',
          hiddenLabel: true,
          tabs: [
            {
              title: '工商信息',
              forms: [
                {
                  type: 'input',
                  label: '法定代表人',
                  key: 'legalPerson',
                  placeholder: '请输入法定代表人',
                  span: 12
                },
                {
                  type: 'input',
                  label: '社会信用代码',
                  key: 'societyCreditCode',
                  placeholder: '请输入社会信用代码',
                  span: 12
                },
                {
                  type: 'input',
                  label: '注册地址',
                  key: 'registeredAddress',
                  placeholder: '请输入注册地址'
                },
                {
                  type: 'input',
                  label: '成立日期',
                  key: 'establishDate',
                  placeholder: '请输入成立日期',
                  span: 12
                },
                {
                  type: 'input',
                  label: '注册资本',
                  key: 'registeredCapital',
                  placeholder: '请输入注册资本',
                  span: 12
                },
                {
                  type: 'input',
                  label: '企业类型',
                  key: 'enterpriseType',
                  placeholder: '请输入企业类型',
                  span: 12
                },
                {
                  type: 'input',
                  label: '营业期限',
                  key: 'businessTerm',
                  placeholder: '请输入营业期限',
                  span: 12
                },
                {
                  type: 'input',
                  comType: 'textarea',
                  label: '营业范围',
                  key: 'businessScope',
                  placeholder: '请输入营业范围'
                }
              ]
            },
            {
              title: '联系信息',
              forms: [
                {
                  type: 'input',
                  label: '联系人',
                  key: 'linkMen',
                  placeholder: '请输入联系人',
                  span: 12
                },
                {
                  type: 'input',
                  label: '手机号码',
                  key: 'mobile',
                  placeholder: '请输入手机号码',
                  span: 12
                },
                {
                  type: 'input',
                  label: '固定电话',
                  key: 'telephone',
                  placeholder: '请输入固定电话',
                  span: 12
                },
                {
                  type: 'input',
                  label: '电子邮箱',
                  key: 'email',
                  placeholder: '请输入电子邮箱',
                  span: 12
                },
                {
                  type: 'input',
                  label: '传真',
                  key: 'fax',
                  placeholder: '请输入传真',
                  span: 12
                }
              ]
            },
            {
              title: '账户信息',
              forms: [
                {
                  type: 'input',
                  label: '对公户名',
                  key: 'accountName',
                  placeholder: '请输入对公户名',
                  span: 12
                },
                {
                  type: 'input',
                  label: '开户银行',
                  key: 'openBank',
                  placeholder: '请输入开户银行',
                  span: 12
                },
                {
                  type: 'input',
                  label: '对公账号',
                  key: 'bankAccout',
                  placeholder: '请输入对公账号',
                  span: 12
                },
                {
                  type: '',
                  hiddenLabel: true
                },
                {
                  type: 'input',
                  label: '对私户名',
                  key: 'privateAccountName',
                  placeholder: '请输入对私户名',
                  span: 12
                },
                {
                  type: 'input',
                  label: '开户银行',
                  key: 'privateOpenBank',
                  placeholder: '请输入开户银行',
                  span: 12
                },
                {
                  type: 'input',
                  label: '对私账号',
                  key: 'privateBankAccount',
                  placeholder: '请输入对私账号',
                  span: 12
                }
              ]
            },
            {
              title: '维护记录',
              type: 'picList',
              key: 'supplierKeepList'
            },
            {
              title: '其他资质',
              type: 'quaList',
              key: 'otherQualifications'
            }
          ]
        }
      ],
      editFormConfig: [
        {
          type: 'input',
          label: '供应商代码',
          key: 'code',
          placeholder: '请输入供应商代码',
          span: 12
        },
        // {
        //   type: 'selectSearch',
        //   label: '绑定用户',
        //   key: 'bingdUserID',
        //   list: [],
        //   placeholder: '请输入绑定用户',
        //   span: 12
        // },
        {
          type: 'input',
          label: '登录账户',
          disabled: true,
          key: 'userAccount',
          placeholder: '请输入登录账户',
          span: 12
        },
        {
          type: 'selectSearch',
          label: '物料类型',
          key: 'categoryCode',
          list: [],
          placeholder: '请选择物料类型',
          span: 12
        },
        {
          type: 'upload',
          label: '供应商名称',
          text: '上传营业执照',
          key: 'name'
        },
        {
          type: 'input',
          label: '账期',
          key: 'accountDate',
          placeholder: '请输入账期',
          span: 12
        },
        {
          type: 'input',
          label: '账期说明',
          key: 'accountDateRemark',
          placeholder: '请输入账期说明',
          span: 12
        },
        {
          type: 'upload-flie',
          label: '营业执照',
          text: '上传营业执照',
          key: 'businessLicense',
        },
        {
          type: 'upload-flie',
          label: 'ca65',
          text: '加州65号法令合规测试证书',
          key: 'certificate'
        },
        {
          type: 'input',
          comType: 'textarea',
          label: '备注',
          key: 'remark',
          placeholder: '请输入仓库说明'
        },
        {
          type: 'tabs',
          hiddenLabel: true,
          tabs: [
            {
              title: '工商信息',
              forms: [
                {
                  type: 'input',
                  label: '法定代表人',
                  key: 'legalPerson',
                  placeholder: '请输入法定代表人',
                  span: 12
                },
                {
                  type: 'input',
                  label: '社会信用代码',
                  key: 'societyCreditCode',
                  placeholder: '请输入社会信用代码',
                  span: 12
                },
                {
                  type: 'input',
                  label: '注册地址',
                  key: 'registeredAddress',
                  placeholder: '请输入注册地址'
                },
                {
                  type: 'input',
                  label: '成立日期',
                  key: 'establishDate',
                  placeholder: '请输入成立日期',
                  span: 12
                },
                {
                  type: 'input',
                  label: '注册资本',
                  key: 'registeredCapital',
                  placeholder: '请输入注册资本',
                  span: 12
                },
                {
                  type: 'input',
                  label: '企业类型',
                  key: 'enterpriseType',
                  placeholder: '请输入企业类型',
                  span: 12
                },
                {
                  type: 'input',
                  label: '营业期限',
                  disabled: true,
                  key: 'businessTerm',
                  placeholder: '请输入营业期限',
                  span: 12
                },
                {
                  type: 'input',
                  comType: 'textarea',
                  label: '营业范围',
                  key: 'businessScope',
                  placeholder: '请输入营业范围'
                }
              ]
            },
            {
              title: '联系信息',
              forms: [
                {
                  type: 'input',
                  label: '联系人',
                  key: 'linkMen',
                  placeholder: '请输入联系人',
                  span: 12
                },
                {
                  type: 'input',
                  label: '手机号码',
                  key: 'mobile',
                  placeholder: '请输入手机号码',
                  span: 12
                },
                {
                  type: 'input',
                  label: '固定电话',
                  key: 'telephone',
                  placeholder: '请输入固定电话',
                  span: 12
                },
                {
                  type: 'input',
                  label: '电子邮箱',
                  key: 'email',
                  placeholder: '请输入电子邮箱',
                  span: 12
                },
                {
                  type: 'input',
                  label: '传真',
                  key: 'fax',
                  placeholder: '请输入传真',
                  span: 12
                }
              ]
            },
            {
              title: '账户信息',
              forms: [
                {
                  type: 'input',
                  label: '对公户名',
                  key: 'accountName',
                  placeholder: '请输入对公户名',
                  span: 12
                },
                {
                  type: 'input',
                  label: '开户银行',
                  key: 'openBank',
                  placeholder: '请输入开户银行',
                  span: 12
                },
                {
                  type: 'input',
                  label: '对公账号',
                  key: 'bankAccout',
                  placeholder: '请输入对公账号',
                  span: 12
                },
                {
                  type: '',
                  hiddenLabel: true
                },
                {
                  type: 'input',
                  label: '对私户名',
                  key: 'privateAccountName',
                  placeholder: '请输入对私户名',
                  span: 12
                },
                {
                  type: 'input',
                  label: '开户银行',
                  key: 'privateOpenBank',
                  placeholder: '请输入开户银行',
                  span: 12
                },
                {
                  type: 'input',
                  label: '对私账号',
                  key: 'privateBankAccount',
                  placeholder: '请输入对私账号',
                  span: 12
                }
              ]
            },
            {
              title: '维护记录',
              type: 'picList',
              key: 'facPicList'
            },
            {
              title: '主营价格',
              type: 'material'
            },
            {
              title: '采购分析',
              type: 'charts'
            },
            {
              title: '维护记录',
              type: 'picList',
              key: 'facPicList'
            },
            {
              title: '其他资质',
              type: 'quaList',
              key: 'facquaList'
            }
            
          ]
        },
      ],
      showFormConfig: [
        {
          type: 'input',
          label: '供应商代码',
          disabled: true,
          key: 'code',
          placeholder: '请输入供应商代码',
          span: 12
        },
        // {
        //   type: 'selectSearch',
        //   label: '绑定用户',
        //   disabled: true,
        //   key: 'bingdUserID',
        //   list: [],
        //   placeholder: '请输入绑定用户',
        //   span: 12
        // },
        {
          type: 'input',
          label: '登录账户',
          disabled: true,
          key: 'userAccount',
          placeholder: '请输入登录账户',
          span: 12
        },
        {
          type: 'selectSearch',
          label: '物料类型',
          key: 'categoryCode',
          disabled: true,
          list: [],
          placeholder: '请选择物料类型',
          span: 12
        },
        {
          type: 'upload',
          label: '供应商名称',
          disabled: true,
          text: '上传营业执照',
          key: 'name'
        },
        {
          type: 'input',
          label: '账期',
          disabled: true,
          key: 'accountDate',
          placeholder: '请输入账期',
          span: 12
        },
        {
          type: 'input',
          label: '账期说明',
          disabled: true,
          key: 'accountDateRemark',
          placeholder: '请输入账期说明',
          span: 12
        },
        {
          type: 'upload-flie',
          label: '营业执照',
          text: '上传营业执照',
          key: 'businessLicense',
        },
        {
          type: 'upload-flie',
          label: 'ca65',
          text: '加州65号法令合规测试证书',
          key: 'certificate'
        },
        {
          type: 'input',
          comType: 'textarea',
          label: '备注',
          disabled: true,
          key: 'remark',
          placeholder: '请输入仓库说明'
        },
        {
          type: 'tabs',
          hiddenLabel: true,
          tabs: [
            {
              title: '工商信息',
              forms: [
                {
                  type: 'input',
                  label: '法定代表人',
                  disabled: true,
                  key: 'legalPerson',
                  placeholder: '请输入法定代表人',
                  span: 12
                },
                {
                  type: 'input',
                  label: '社会信用代码',
                  disabled: true,
                  key: 'societyCreditCode',
                  placeholder: '请输入社会信用代码',
                  span: 12
                },
                {
                  type: 'input',
                  label: '注册地址',
                  disabled: true,
                  key: 'registeredAddress',
                  placeholder: '请输入注册地址'
                },
                {
                  type: 'input',
                  label: '成立日期',
                  disabled: true,
                  key: 'establishDate',
                  placeholder: '请输入成立日期',
                  span: 12
                },
                {
                  type: 'input',
                  label: '注册资本',
                  disabled: true,
                  key: 'registeredCapital',
                  placeholder: '请输入注册资本',
                  span: 12
                },
                {
                  type: 'input',
                  label: '企业类型',
                  disabled: true,
                  key: 'enterpriseType',
                  placeholder: '请输入企业类型',
                  span: 12
                },
                {
                  type: 'input',
                  label: '营业期限',
                  disabled: true,
                  key: 'businessTerm',
                  placeholder: '请输入营业期限',
                  span: 12
                },
                {
                  type: 'input',
                  comType: 'textarea',
                  label: '营业范围',
                  disabled: true,
                  key: 'businessScope',
                  placeholder: '请输入营业范围'
                }
              ]
            },
            {
              title: '联系信息',
              forms: [
                {
                  type: 'input',
                  label: '联系人',
                  disabled: true,
                  key: 'linkMen',
                  placeholder: '请输入联系人',
                  span: 12
                },
                {
                  type: 'input',
                  label: '手机号码',
                  disabled: true,
                  key: 'mobile',
                  placeholder: '请输入手机号码',
                  span: 12
                },
                {
                  type: 'input',
                  label: '固定电话',
                  disabled: true,
                  key: 'telephone',
                  placeholder: '请输入固定电话',
                  span: 12
                },
                {
                  type: 'input',
                  label: '电子邮箱',
                  disabled: true,
                  key: 'email',
                  placeholder: '请输入电子邮箱',
                  span: 12
                },
                {
                  type: 'input',
                  label: '传真',
                  disabled: true,
                  key: 'fax',
                  placeholder: '请输入传真',
                  span: 12
                }
              ]
            },
            {
              title: '账户信息',
              forms: [
                {
                  type: 'input',
                  label: '对公户名',
                  disabled: true,
                  key: 'accountName',
                  placeholder: '请输入对公户名',
                  span: 12
                },
                {
                  type: 'input',
                  label: '开户银行',
                  disabled: true,
                  key: 'openBank',
                  placeholder: '请输入开户银行',
                  span: 12
                },
                {
                  type: 'input',
                  label: '对公账号',
                  disabled: true,
                  key: 'bankAccout',
                  placeholder: '请输入对公账号',
                  span: 12
                },
                {
                  type: '',
                  hiddenLabel: true
                },
                {
                  type: 'input',
                  label: '对私户名',
                  disabled: true,
                  key: 'privateAccountName',
                  placeholder: '请输入对私户名',
                  span: 12
                },
                {
                  type: 'input',
                  label: '开户银行',
                  disabled: true,
                  key: 'privateOpenBank',
                  placeholder: '请输入开户银行',
                  span: 12
                },
                {
                  type: 'input',
                  label: '对私账号',
                  disabled: true,
                  key: 'privateBankAccount',
                  placeholder: '请输入对私账号',
                  span: 12
                }
              ]
            },
            {
              title: '维护记录',
              type: 'picList',
              key: 'facPicList'
            },
            {
              title: '主营价格',
              type: 'material'
            },
            {
              title: '采购分析',
              type: 'charts'
            },
            {
              title: '其他资质',
              type: 'quaList',
              key: 'facquaList'
            }
          ]
        }
      ],
      columns: [
        {
          title: '序号',
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '供应商代码',
          key: 'supplierCoded',
          minWidth: 100
        },
        {
          title: '供应商名称',
          key: 'supplierName',
          minWidth: 300,
          render(h,p){
            return h(renderListimgs,{
              props: {
                row: p.row
              }
            })
          },
        },
        {
          title: '物料类型',
          key: 'malssifyName',
          minWidth: 150
        },
        {
          title: '账期',
          key: 'accountDate',
          minWidth: 100
        },
        {
          title: '采购周期',
          key: 'accountDateRemark',
          minWidth: 100,
          render:(h,p)=>{
            return h('span',{
              style:{
                color:'#0077ff',
                cursor:"pointer"
              },
              on: {
                click: () => {
                  
                  this.$post('/api/storage-restructure/material/getMaterialBySupplierId',{supplierId:p.row.id}).then(res=>{
                    this.accountDateRemarkModalData = res.data
                    this.accountDateRemarkModal = true
                  })
                  
                  
                }
              }
            },
              '查看'
            )
          }
        },
        {
          title: '账期说明',
          key: 'accountDateRemark',
          minWidth: 100
        },
        {
          title: '联系人',
          key: 'linkMen',
          minWidth: 100
        },
        {
          title: '联系电话',
          key: 'telephone',
          minWidth: 150
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          fixed: 'right',
          width: 150,
          render: (h, params) => {
            const v  = this
            return h('div', [
              h(
                'Icon',
                {
                  props: {
                    custom: 'iconfont icon-chakan',
                    size: '20',
                    color: '#6bc01e'
                  },
                  style: {
                    marginRight: '20px'
                  },
                  on: {
                    click: () => {
                      this.getDtl('form',params.row.id)
                      
                      
                    }
                  }
                },
                '查看明细'
              ),
              h(
                'Icon',
                {
                  props: {
                    custom: 'iconfont icon-edit',
                    size: '20',
                    color: '#087BE1'
                  },
                  style: {
                    marginRight: '20px'
                  },
                  on: {
                    click: () => {
                      this.getDtl('edit',params.row.id)
                      
                    }
                  }
                },
                '修改'
              ),
              h(
                'Icon',
                {
                  props: {
                    custom: 'iconfont icon-delete',
                    size: '20',
                    color: 'red'
                  },
                  on: {
                    click: () => {
                      this.$MyModal.show({ text: '是否删除？' }).$on('confirm', () => {
                        this.$post('/api/storage-restructure/supplier/delete',{id:params.row.id}).then(res=>{
                          if (res.code == 200) {
                            v.$Message.info(res.msg)
                            v.getList()
                          }
                        })
                      })
                    }
                  }
                },
                '删除'
              )
            ])
          }
        }
      ],
      accountDateRemarkModalcolumns:[
        {
          title: '序号',
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '物料编码',
          key: 'materialCode'
        },
        {
          title: '面料名称',
          key: 'materialName'
        },
        {
          title: '采购周期',
          key: 'safetyWarnDay'
        },
      ],
      accountDateRemarkModalData:[],
      accountDateRemarkModal:false,
      tableFilter: [
        {
          name: 'Input',
          value: 'keyword',
          placeholder: '请输入关键字'
        },
        {
          name: 'Button',
          type: 'primary',
          text: '查询',
          e: 'search'
        },
        {
          name: 'Button',
          type: 'primary',
          text: '添加',
          align: 'right',
          e: 'add'
        },
        {
          name: 'Button',
          type: 'primary',
          text: '价格维护',
          align: 'right',
          e: 'priceHandle'
        },
        {
          name: 'Button',
          type: 'primary',
          text: '收款账号维护',
          align: 'right',
          width: '300',
          e: 'account'
        }
      ],
      params: {
        pageNum: 1,
        pageSize: 10,
        total: 0,
        TechnologyType:99,
        Purpose:null,
        search:null,
      },
      total:0,
      loading:false,
      selectPurposeList:[],
      accountDateList:[],
      safetyWarnDayList:[],
    }
  },
  methods: {
    getDtl(formType,id){
      this.$post('/api/storage-restructure/supplier/details',{id:id}).then(res=>{    
        this.formData = {...this.formData,...res.data}
        this.formType = formType
        this.title = '供应商详情'
        this.show = true
      })
      this.$post('/api/storage-restructure/supplierContacts/details',{id:id}).then(res=>{    
        this.formData = {...this.formData,...res.data}
      })
      this.$post('/api/storage-restructure/supplierBank/details',{id:id}).then(res=>{    
        this.formData = {...this.formData,...res.data}
      })
      
    },
    getSafetyWarnDayList(){
      const v = this
      this.$post('/api/storage-restructure/supplier/getSafetyWarnDay',{}).then(res=>{
        console.log(res)
        v.safetyWarnDayList = res.data
      })
      
    },
    getAccountDateList(){
      const v = this
      this.$post('/api/storage-restructure/supplier/getAccountDate',{}).then(res=>{
        console.log(res)
        v.accountDateList = res.data
      })
      
    },
  
    selectPurposeFn(e){
      console.log(e)
      if(e == 999){
        this.params.Purpose = ''
      }else{
        this.params.Purpose = this.selectPurposeList[e].purpose
      }
      
    },
    cfm (type, formData) {
      const formDataCopy = {
          ...formData,
          supplierBank:{
            accountName:formData.accountName,
            openBank:formData.openBank,
            bankAccount:formData.bankAccount,
            privateAccountName:formData.privateAccountName,
            privateOpenBank:formData.privateOpenBank,
            privateBankAccount:formData.privateBankAccount,
          },
          supplierContacts:{
            linkMen:formData.linkMen,
            mobile:formData.mobile,
            telephone:formData.telephone,
            email:formData.email,
            fax:formData.fax,
          },
          supplierKeepList:[],
          otherQualifications:[],
        }
      if (type === 'add') {
        

        this.$post('/api/storage-restructure/supplier/add',formDataCopy).then(res=>{
          this.show = false
          if(res.code === 200){
            this.show = false
            this.$Message.info(res.msg)
            this.getList()
          }
        })
      } else if (type === 'edit') {
        this.$post('/api/storage-restructure/supplier/edit',formDataCopy).then(res=>{
          this.$Message.info(res.msg)
          this.getList()
          this.show = false
        })
        
      }
    },
    // 检索条件事件处理
    eventHandle (option) {
      switch (option) {
        case 'search':
          console.log(option)
          this.params.pageNum = 1
          this.params.keyword = option.keyword
          this.getList()
          break
        case 'add':
          this.formType = 'add'
          this.title = '添加供应商'
          this.show = true
          break
        case 'priceHandle':
          this.$router.push({
            name: 'provider_price_maintenance'
          })
          break
        case 'account':
          this.accountShow = true
          break
      }
    },
    changePage (pageNum) {
      this.params.pageNum = pageNum
      this.getList()
    },
    getMaterialCategoryZTree () {
      this
				.$post(
					'/api/storage-restructure/materialClassify/tree')
				.then((res) => {
          for (let i = 0; i < res.data.length; i++) {
            const element = res.data[i];
            element.label = element.name
            element.value = element.id
          }
          
          console.log(res.data)
					this.formConfig[2].list = res.data
          this.editFormConfig[2].list = res.data
          this.showFormConfig[2].list = res.data
				})
     
    },
    getUserPageList () {
      GetUserPageList({
        pageNum: 1,
        pageSize: 9999
      }).then(res => {
        if (res.code === 0) {
          let list = res.result.list.map(item => {
            return {
              label: item.realName,
              value: item.id
            }
          })
          this.formConfig[1].list = list
          this.editFormConfig[1].list = list
          this.showFormConfig[1].list = list
        }
      })
    },
    getList () {
      this.$post('/api/storage-restructure/supplier/page', {...this.params})
				.then((res) => {
					this.data = res.data.records
          this.params.total = res.data.total
				})        
      // GetFactoryPageList(this.params).then(res => {
      //   if (res.code === 0) {
      //     this.data = res.result.list
      //     this.params.total = res.result.totalCount
      //   }
      // })
    },
    getMaterialSelectPurposeList(){
      const v = this
      v.loading = true
      v.$post('/api/storage-restructure/material/getPurpose', {})
        .then((res) => {
          
          v.selectPurposeList = res.data
          v.loading = false
        })
    },

    getSupplierSelectList(req){
      const v = this
      v.loading = true
      this.$post('/api/storage-restructure/supplier/page', {pageNum:1,pageSize:999})
				.then((res) => {
					this.supplierList = res.data.records
          this.params.total = res.data.total
          v.loading = false
				})  
      
    },
    getStatisticsClassify(){
      this
				.$post(
					'/api/storage-restructure/supplier/getStatistics',this.params)
				.then((res) => {
          
					this.statisticsClassifyData = res.data
					
				})
      }
    
  },
  mounted () {
    this.getList()
    // this.getUserPageList()
    this.getMaterialCategoryZTree()
    this.getStatisticsClassify()
    // this.getSupplierSelectList()
    this.getMaterialSelectPurposeList()
    this.getAccountDateList()
    this.getSafetyWarnDayList()
    //this.socketInit()
  }
}
</script>

<style lang="less" scoped>
.container {
  
  .tabs-warp{
    height: 60px;
    line-height: 60px;
    border-bottom: 1px solid #979797;
    margin-bottom: 10px;
    display: flex;
    
    div{
      width: 20%;
      font-size: 16px;
      text-align: center;
      position: relative;
      cursor: pointer;
      span{
        color:#EF0000
      }
    }
    div.active::before{
      position: absolute;
      content:" ";
      left: 0;
      right:0;
      bottom:0;
      height:4px;
      background: #1A3AF0;
    }
  }
}
</style>
