
export default {
  computed: {
    formItems() {
      return [{
        md: 24,
        name: 'slot-component',
        formItemAttributes: {
          label: '基本信息',
        },
        render: (h, { props, onInput }) => {
          var { formData } = props
          return (
            <el-descriptions border title="" column={2} colon={false} labelStyle={{ width: '13%' }} contentStyle={{ width: '37%' }}>
              <el-descriptions-item label="所属商户">
                {formData.companyWechatName}
              </el-descriptions-item>
              <el-descriptions-item label="申请单号">
                {formData.orderId}
              </el-descriptions-item>
              <el-descriptions-item label="项目名称">
                {formData.rpProjectRepairName}
              </el-descriptions-item>
              <el-descriptions-item label="工单单号">
                {formData.workerOrderId}
              </el-descriptions-item>
              <el-descriptions-item label="负责人">
                {formData.userName}
              </el-descriptions-item>
              <el-descriptions-item label="联系电话">
                {formData.userMobile}
              </el-descriptions-item>
              <el-descriptions-item label="项目地址">
                {formData.pgOrderBase.address}
              </el-descriptions-item>
              <el-descriptions-item label="创单人">
                {formData.pgOrderBase.createBy}
              </el-descriptions-item>
              <el-descriptions-item label="创单人电话">
                {formData.pgOrderBase.createMobile}
              </el-descriptions-item>
              <el-descriptions-item label="创单时间">
                {formData.pgOrderBase.createTime}
              </el-descriptions-item>
              <el-descriptions-item label="工单类型">
                {formData.orderSmallTypeText}
              </el-descriptions-item>
              <el-descriptions-item label="网点名称">
                {formData.websitName}
              </el-descriptions-item>
              <el-descriptions-item label="申请人">
                {formData.workerName}
              </el-descriptions-item>
              <el-descriptions-item label="联系电话">
                {formData.workerMobile}
              </el-descriptions-item>
              <el-descriptions-item label="申请时间">
                {formData.createTime}
              </el-descriptions-item>
              <el-descriptions-item label="包含全部费用">
                {({ YES: "是", NO: "否" })[formData.isAllFee]}
              </el-descriptions-item>

              {!!~["applicationWithoutFee", "feeSettlementIncluded", "feeSettlementIncludedwx"].indexOf(this?.$route?.name) ? <el-descriptions-item label="费用支付方式">
                {({ EXAMINE: "审批后结算", SITE: "现场支付" })[formData.feePayMethod]}
              </el-descriptions-item> : null}

              {!!~["applicationWithoutFee"].indexOf(this?.$route?.name) && formData.feePayMethod == "EXAMINE" ? [
                <el-descriptions-item label="费用单状态">
                  {({ WAIT: "待审", OK: "通过", FAIL: "驳回", PAID: "现场支付", NO: "取消", NO_PAID: "未支付" })[formData.examineStatus]}
                </el-descriptions-item>,
                <el-descriptions-item label="审批人">
                  {formData.examineName}
                </el-descriptions-item>,
                <el-descriptions-item label="审批时间">
                  {formData.examineTime}
                </el-descriptions-item>,
                <el-descriptions-item label="取消人">
                  {formData.cancelName}
                </el-descriptions-item>,
                <el-descriptions-item label="取消时间">
                  {formData.cancelTime}
                </el-descriptions-item>
              ] : null}

              {!!~["feeSettlementIncluded"].indexOf(this?.$route?.name) && formData.feePayMethod == "EXAMINE" ? [
                <el-descriptions-item label="结算状态">
                  {({ WAIT: "待结算", OVER: "已结算" })[formData.status]}
                </el-descriptions-item>,
                <el-descriptions-item label="结算人">
                  {formData.settleName}
                </el-descriptions-item>,
                <el-descriptions-item label="结算时间">
                  {formData.settleTime}
                </el-descriptions-item>
              ] : null}
            </el-descriptions>
          )
        }
      }, {
        md: 24,
        name: 'slot-component',
        formItemAttributes: {
          label: '费用明细',
        },
        render: (h, { props, onInput }) => {
          var { formData } = props
          return (
            <zj-table
              columns={[{
                columnAttributes: {
                  label: '费用名称',
                  prop: 'goodsName',
                }
              }, {
                columnAttributes: {
                  label: '费用类型',
                  prop: 'chargeType',
                },
                render: (h, { row, column, index }) => {
                  return (
                    <div style="padding-left:10px">
                      {({ MCC: "辅材物料", ACC: "配件物料", SERV: "服务收费" })[row.chargeType]}
                    </div>
                  )
                }
              }, {
                columnAttributes: {
                  label: '单价',
                  prop: 'goodsAmount',
                }
              }, {
                columnAttributes: {
                  label: '数量',
                  prop: 'num',
                }
              }, {
                columnAttributes: {
                  label: '费用金额',
                  prop: 'totalAmount',
                }
              },
              ]}
              table-data={formData.rpMaterialOrderItems}
            />
          )
        }
      },
      {
        md: 8,
        isShow: this.formData.rpMaterialOrderItems.filter(item => item.chargeType == "MCC").length,
        name: 'slot-component',
        formItemAttributes: {
          label: '辅材费用合计',
        },
        render: (h, { props, onInput }) => {
          var { formData } = props
          return <span>{[0, 0, 0, ...formData.rpMaterialOrderItems.filter(item => item.chargeType == "MCC").map(item => item.totalAmount)].reduce(function (prev, curr, idx, arr) {
            return prev + curr;
          }).toFixed(2)}</span>
        }
      },
      {
        md: 8,
        isShow: this.formData.rpMaterialOrderItems.filter(item => item.chargeType == "ACC").length,
        name: 'slot-component',
        formItemAttributes: {
          label: '配件费用合计',
        },
        render: (h, { props, onInput }) => {
          var { formData } = props
          return <span>{[0, 0, 0, ...formData.rpMaterialOrderItems.filter(item => item.chargeType == "ACC").map(item => item.totalAmount)].reduce(function (prev, curr, idx, arr) {
            return prev + curr;
          }).toFixed(2)}</span>
        }
      },
      {
        md: 8,
        name: 'slot-component',
        formItemAttributes: {
          label: '服务收费费用合计',
        },
        render: (h, { props, onInput }) => {
          var { formData } = props
          return <span>{[0, 0, 0, ...formData.rpMaterialOrderItems.filter(item => item.chargeType == "SERV").map(item => item.totalAmount)].reduce(function (prev, curr, idx, arr) {
            return prev + curr;
          }).toFixed(2)}</span>
        }
      },
      {
        md: 8,
        name: 'slot-component',
        formItemAttributes: {
          label: '总金额',
        },
        render: (h, { props, onInput }) => {
          var { formData } = props
          return <span>{[0, 0, 0, ...formData.rpMaterialOrderItems.map(item => item.totalAmount)].reduce(function (prev, curr, idx, arr) {
            return prev + curr;
          }).toFixed(2)}</span>
        }
      }, {
        name: 'el-input',
        md: 24,
        attributes: { disabled: true, type: "textarea", placeholder: '' },
        formItemAttributes: { label: '申请备注', prop: 'remark' },
      },
      ...(() => {
        if (this.formData.payType == 'WECHAT') {
          return [{
            md: 24,
            name: 'slot-component',
            formItemAttributes: {
              label: '交易记录',
            },
            render: (h, { props, onInput }) => {
              var { formData } = props
              return (
                <zj-table
                  columns={[{
                    columnAttributes: {
                      label: 'id',
                      prop: 'orderId',
                    }
                  }, {
                    columnAttributes: {
                      label: '交易类型',
                      prop: 'goodsType',
                    },
                    render: (h, { row }) => {
                      return <div>
                        {({ M: "辅材", P: "配件" })[row.goodsType]}
                      </div>
                    }
                  }, {
                    columnAttributes: {
                      label: '交易金额',
                      prop: 'totalAmount',
                    }
                  }, {
                    columnAttributes: {
                      label: '交易状态',
                      prop: 'payStatus',
                    },
                    render: (h, { row }) => {
                      return <div>
                        {({ CANCEL: "取消", WAIT: "待支付", PAID: "已支付" })[row.payStatus]}
                      </div>
                    }
                  }, {
                    columnAttributes: {
                      label: '交易时间',
                      prop: 'payTime',
                    }
                  }, {
                    columnAttributes: {
                      label: '创建时间',
                      prop: 'createTime',
                    }
                  }]}
                  table-data={[formData]}
                />
              )
            }
          }]
        }
        return []
      })()]
    }
  }
}