广州矛调粤政易端
xusd
7 days ago d27794814b69d18aeb8ee96a46cae91d5613570c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * @Company: hugeInfo
 * @Author: lwh
 * @Date: 2023-08-22 09:09:28
 * @LastEditTime: 2023-10-18 14:47:38
 * @LastEditors: dminyi 1301963064@qq.com
 * @Version: 1.0.0
 * @Description: 
 */
import React, { useState } from 'react';
import { TelephoneOutlined } from 'dd-icons';
import { Space, Button } from 'dingtalk-design-mobile';
import { dateFormat } from '../../utils/utility';
import './index.less';
 
/**
 * list: array, // 列表模型
 * data: object, // 对象数据
 * marginTop: bool, // 是否有上边距
 * marginBottom: bool, // 是否有下边距
 * detailClick: fun   //查看按钮
 */
const InfoViewModal = ({ list, data, OnClick, detailClick, showButtons = true }) => {
 
 
  function typeChange(x) {
    switch (x.type) {
      case 'text':
        return (
          <div className="infoView-card" style={{ paddingTop: x.paddingTop && '12px', paddingBottom: x.paddingBottom && '12px' }}>
            <div className="infoView-card-title">{x.title}</div>
            <div className="infoView-card-value">
              {x.value === "userTotal" || x.value === 'personAmount' ? (
                <span>
                  {data[x.value] || 0}{x.unit}
                </span>
              ) : x.value === 'onDuty' ? (
                <span>
                  {data[x.value] === 1 ? '是' : '否'}
                </span>
              ) : (
                data[x.value] !== null ? (
                  <span>
                    {data[x.value]}
                  </span>
                ) : (
                  <span>-</span>
                )
              )}
 
              {data[x.value] > 0 && x.value !== 'posCount' && x.clickableText && (
                <span onClick={() => detailClick(x.title, data.coreId)} className='public-color'>&nbsp;&nbsp;{x.clickableText}</span>
              )}
            </div>
          </div >
        );
      case 'time':
        return (
          <div className="infoView-card" style={{ paddingTop: x.paddingTop && '12px', paddingBottom: x.paddingBottom && '12px' }}>
            <div className="infoView-card-title">{x.title}</div>
            <div className="infoView-card-value">{data[x.value] ? dateFormat(data[x.value]) : '-'}</div>
          </div >
        );
      case 'build':
        return;
      default:
        return;
    }
  }
 
 
  return (
    <div className="infoView1">
      <div className="infoView1-main" >
        {list.map((x, t) => {
          return <div key={t}>{typeChange(x)}</div>;
        })}
      </div>
 
      {showButtons && (
        <div className='infoView-foot-button'>
          <Button
            onClick={() => { OnClick('del') }}
            className='infoView-foot-button-del'
            style={{ flex: 1, marginRight: '8px', border: '1px solid #F5222D', color: '#F5222D' }}
          >
            删除
          </Button>
          <Button
            className='infoView-foot-button-edit'
            type="primary" onClick={() => {
              OnClick('edit');
            }}>
            修改
          </Button>
        </div>
      )}
    </div>
  )
 
};
 
 
export default InfoViewModal;