/*
  @description:立项采购-公用字典
  @Modifier:qk/gmy
  @routerPath:
  @date:2020-6-3 17:49
*/
/* api*/
/* 混合开发*/
import { initGroupMixin } from '@/mixins/initGroupMixin' // 全局公用字典
import { queryPurchasePlanInitInfo } from '@/api/procurement/purchasplan'// 采购计划公共字典
import { queryProcurementProjectInitInfo, queryProcurementProjectRuleInitInfo } from '@/api/procurement/procurementProject' // 采购立项的采购方式字典 queryProcurementProjectRuleInitInfo

export const procurementProjectGroupMixin = {
  data() {
    return {
      /* ==============================采购项目信息-接口回显==============================*/
      // 采购方式
      tendermethodList: [], // 采购方式
      protprojectPurchaseSupplierStatusList: [], // 采购项目供应商对应项目状态
      protprojectPurchaseProjectStatusList1: [], // 采购单状态搜索时去除流标
      protprojectPurchaseProjectStatusList: [], // 采购项目采购状态
      protprojectPurchaseResultStatusList: [], // 采购项目是否中标状态
      measuringUnitList: [], // 计量单位
      /* ==============================采购项目规则-接口回显==============================*/
      isPublicSupplierName:
        [{ typecode: '00', typename: '公开' },
          { typecode: '01', typename: '不公开' }], // 公开竞价方名称
      isPublicSupplierCount:
        [{ typecode: '00', typename: '公开' },
          { typecode: '01', typename: '不公开' }], // 是否公开参与的竞价家数
      reviewMethod:
        [{ typecode: '01', typename: '综合评估法' },
          { typecode: '02', typename: '经评审的有效最低价' }
        ], // 评审办法
      quotePriceMethod:
        [{ typecode: '00', typename: '报总价 ' },
          { typecode: '01', typename: '分项报价' }], // 报价方式
      comparePriceType:
        [{ typecode: '00', typename: '竞价格' },
          { typecode: '01', typename: '竞价扣率' }], // 竞价类型
      isPublicSupplierPrice:
        [{ typecode: '00', typename: '公开' },
          { typecode: '01', typename: '不公开' }], // 是否公开报价金额
      documentPrice:
        [{ typecode: '00', typename: '否' },
          { typecode: '01', typename: '是' }
        ], // 是否收取标书费
      signupAudit:
        [{ typecode: '00', typename: '不审核' },
          { typecode: '01', typename: '审核' }], // 审核报名
      comparePriceMethod:
        [{ typecode: '00', typename: '竞高价' },
          { typecode: '01', typename: ' 竞低价' }], // 竞价方式
      quoteTimeUnit: [], // 竞价时长单位
      quoteOutTimeUnit: [], // 超时竞价单位
      quoteOutTimeAddTimeUnit: [], // 超时竞价延长单位
      invoiceType:
        [{ typecode: '00', typename: '普通发票' },
          { typecode: '01', typename: '增值税专用发票' }], // 发票要求
      bailPrice:
        [{ typecode: '00', typename: '不收取' },
          { typecode: '01', typename: '收取' }
        ], // 是否收取保证金
      quoteRangeType:
        [{ typecode: '00', typename: '无限制' },
          { typecode: '01', typename: '最低幅度' }], // 报价最小幅度
      quoteType: [], // 报价要求
      isPublicSupplierRanking:
        [{ typecode: '00', typename: '公开' },
          { typecode: '01', typename: '不公开' }], // 是否公开竞价排名
      autoExtension: [{ typecode: '00', typename: '延期' },
        { typecode: '01', typename: '不延期' }], // 自动延期
      documentSaleMethod: [], // 标书费售卖方式
      bailPriceMethod: [], // 保证金收取方式
      isFile:
        [{ typecode: '00', typename: '不制作' },
          { typecode: '01', typename: '制作' }], // 制作采购文件
      quoteCountType: [{ typecode: '00', typename: '无限制' },
        { typecode: '01', typename: '总报价' }], // 报价次数
      protproject_quoteMethodList:
        [{ typecode: '01', typename: '一次报价' }
        ], // 询价方式
      isAcceptArr:
        [{ typecode: '01', typename: '是' },
          { typecode: '02', typename: '否' }], // 过期未接受
      /* ==============================采购项目规则-接口回显新增==============================*/
      // 支付方式
      payTypelist: [{ typecode: '00', typename: '货到验收后付款' }, { typecode: '01', typename: '质保金' }, { typecode: '02', typename: '货到付款' }, { typecode: '03', typename: '其他' }],
      // 是否公示
      isPublicList: [{ typecode: '00', typename: '否' }, { typecode: '01', typename: '是' }],
      // 是否强制上传应答文件
      uploadReplyFileList: [{ typecode: '00', typename: '否' }, { typecode: '01', typename: '是' }],
      // 是否紧急采购
      emergencyProcurementList: [{ typecode: '00', typename: '否' }, { typecode: '01', typename: '是' }],
      // 货币
      currencyList: [{ typecode: '00', typename: '人民币' }, { typecode: '01', typename: '美元' }, { typecode: '01', typename: '欧元' }],
      // 是否包含运费
      containsFreightList: [{ typecode: '00', typename: '否' }, { typecode: '01', typename: '是' }],
      //  采购类型
      plan_purchase_typeList: [],
      //  物资类型
      purchaseTypeList: [{ typecode: '00', typename: '物资' }, { typecode: '01', typename: '施工' }, { typecode: '02', typename: '服务' }],
      // 采购计划采购方式
      tender_methodList: [],
      purchaseIndustryNameList: [],
      // 采购的组织形式
      tenderOrgMethodList: [
        { typecode: '00', typename: '自采' },
        { typecode: '01', typename: '委托采购' }
      ],
      // 项目类型
      tendertypeList: [
        { typecode: '00', typename: '公开' },
        { typecode: '01', typename: '邀请' }
      ],
      // 是否使用工具制作采购文件
      procurementFileList: [
        { typecode: '00', typename: '是' },
        { typecode: '01', typename: '否' }
      ],
      // 报价状态
      quotationStatusList: [
        { typecode: '00', typename: '未报价' },
        { typecode: '01', typename: '已报价' },
        { typecode: '02', typename: '报价撤销' },
        { typecode: '03', typename: '未报价' },
        { typecode: '04', typename: '报价撤销' },
        { typecode: '05', typename: '未报价' },
        { typecode: '06', typename: '已报价' }
      ],
      // 税率
      taxRate: [],
      // 采购计划来源
      plan_source_type: [],
      organization: [], // 采购的组织形式
      supplierCategoryList: [], // 供应商分类
      supplierAttributeList: [], // 供应商属性
      ifComboTypeList: [] // 是否联合体
    }
  },
  mixins: [initGroupMixin], // 公共方法
  created() {
    this.getGroupType()
  },
  methods: {
    getGroupType() {
      const dictionaryType = ['ifComboType'] // 字典请求参数
      this.$store.dispatch('getGroupType', dictionaryType).then((data) => {
        // 遍历key存储相应的数据
        for (const key in data.bidTypeData) {
          /* 是否有数据*/
          if (data.bidTypeData[key]) {
            this[key] = data.bidTypeData[key]
          }
        }
      })
    },
    /* ==============================立项采购-接口回显==============================*/
    // 查询字典
    inCodes() {
      queryProcurementProjectInitInfo().then(res => {
        // 获取采购方式
        this.tendermethodList = res.data.tender_method.typeList
        // 采购项目供应商对应项目状态
        this.protprojectPurchaseSupplierStatusList = res.data.protprojectPurchaseSupplierStatus.typeList // 供应商项目状态字典
        this.protprojectPurchaseProjectStatusList = res.data.protprojectPurchaseProjectStatus.typeList // 采购管理项目状态
        this.protprojectPurchaseResultStatusList = res.data.protprojectPurchaseResultStatus.typeList // 供应商项目是否中标字典
        this.measuringUnitList = res.data.purchaseUnit.typeList // 计量单位
        this.purchaseIndustryNameList = res.data.purchaseIndustryName.typeList // 项目类型
        this.protprojectPurchaseProjectStatusList1 = this.protprojectPurchaseProjectStatusList.filter(item => item.typecode !== '08')
      }).catch(() => {
      })
    },
    // 项目规则字典
    initqueryProcurementProjectRuleInitInfo() {
      queryProcurementProjectRuleInitInfo().then(res => {
        this.isPublicSupplierName = res.data.protproject_isPublicSupplierName.typeList // 公开竞价方名称
        this.isPublicSupplierCount = res.data.protproject_isPublicSupplierCount.typeList // 是否公开参与的竞价家数
        this.reviewMethod = res.data.protproject_reviewMethod.typeList //
        this.comparePriceType = res.data.protproject_comparePriceType.typeList // 竞价类型
        this.isPublicSupplierPrice = res.data.protproject_isPublicSupplierPrice.typeList // 是否公开报价金额
        this.documentPrice = res.data.protproject_documentPrice.typeList // 是否收取标书费
        this.signupAudit = res.data.protproject_signupAudit.typeList // 审核报名
        this.comparePriceMethod = res.data.protproject_comparePriceMethod.typeList // 竞价方式
        this.quoteOutTimeUnit = res.data.protproject_quoteOutTimeUnit.typeList // 超时竞价单位
        this.invoiceType = res.data.protproject_invoiceType.typeList // 发票要求
        this.quoteOutTimeAddTimeUnit = res.data.protproject_quoteOutTimeAddTimeUnit.typeList // 超时竞价延长单位
        this.bailPrice = res.data.protproject_bailPrice.typeList // 是否收取保证金
        this.quoteRangeType = res.data.protproject_quoteRangeType.typeList // 报价最小幅度
        this.quoteType = res.data.protproject_quoteType.typeList // 报价要求
        this.isPublicSupplierRanking = res.data.protproject_isPublicSupplierRanking.typeList // 是否公开竞价排名
        this.documentSaleMethod = res.data.protproject_documentSaleMethod.typeList // 标书费售卖方式
        this.quoteTimeUnit = res.data.protproject_quoteTimeUnit.typeList // 竞价时长单位
        this.bailPriceMethod = res.data.protproject_bailPriceMethod.typeList // 保证金收取方式
        this.quoteCountType = res.data.protproject_quoteCountType.typeList // 报价次数
        this.supplierCategoryList = res.data.supplierCategory.typeList // 供应商分类
        this.supplierAttributeList = res.data.supplierAttribute.typeList // 供应商属性
        // 新增
        this.containsFreightList = res.data.protproject_containsFreight.typeList // 是否包含运费
        this.currencyList = res.data.protproject_currency.typeList // 币种
        this.emergencyProcurementList = res.data.protproject_emergencyProcurement.typeList // 是否紧急采购
        this.uploadReplyFileList = res.data.protproject_uploadReplyFile.typeList // 是否强制上传应答文件
        this.isPublicList = res.data.protproject_isPublic.typeList // 是否公示
        this.payTypelist = res.data.protproject_payType.typeList // 支付方式
        this.protproject_quoteMethodList = res.data.protproject_quoteMethod.typeList
      })
    },
    // 字典信息-项目类型
    initWebTypeGroup() {
      queryPurchasePlanInitInfo().then(res => {
        this.plan_source_type = res.data.plan_source_type.typeList // 采购计划来源
        this.plan_purchase_typeList = res.data.plan_purchase_type.typeList
        this.tender_methodList = res.data.tender_method.typeList // 采购方式
        this.organization = res.data.plan_purchase_organization.typeList // 采购组织形式 00 自采 01委托
        this.tenderTypeList = res.data.tenderType.typeList // 公开/邀请
        this.taxRate = res.data.taxRate.typeList // 税率
      })
    }
  }
}
