hcong
2024-11-15 18eee6f8818b864d1f8d8fb56298620921f909e4
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<template>
  <table>
    <tbody>
      <tr>
        <td colspan="2">{{ title }}</td>
      </tr>
      <tr>
        <td style="position: relative">
          <el-image
            class="image"
            :src="seletcedProblemPic"
            :preview-src-list="seletcedProblemPic ? [seletcedProblemPic] : []"
            :initial-index="0"
            fit="cover"
            lazy
          >
            <template #error v-if="!seletcedProblemPic">
              <div class="image-slot">
                <el-text>问题图片未上传</el-text>
              </div>
            </template>
          </el-image>
          <el-button
            class="pop-button"
            size="small"
            @click="proDialog = true"
            >{{ btnName }}</el-button
          >
        </td>
        <td style="position: relative">
          <el-image
            class="image"
            :src="seletcedChangePic ? seletcedChangePic : unchangeImg"
            :preview-src-list="seletcedChangePic ? [seletcedChangePic] : []"
            :initial-index="0"
            fit="cover"
            lazy
          />
          <el-button
            class="pop-button"
            size="small"
            @click="changeDialog = true"
            >{{ btnName }}</el-button
          >
        </td>
      </tr>
      <tr>
        <td>
          <div>位置:{{ problem.location }}</div>
          <div>
            描述:
            <el-input
              size="small"
              v-model="problemDes"
              placeholder="问题描述"
              style="width: 150px"
            />
          </div>
        </td>
        <td>
          <div>位置:{{ problem.location }}</div>
          <div>
            描述:
            <el-input
              size="small"
              v-model="changeDes"
              placeholder="整改描述"
              style="width: 150px"
            />
          </div>
        </td>
      </tr>
    </tbody>
  </table>
  <CompProblemPicSelect
    v-if="pics.length > 0"
    title="问题图片"
    v-model:dialog-visible="proDialog"
    mode="problem"
    :pics="pics[0].path"
    :defaultFile="[{ url: seletcedProblemPic }]"
    @submit="handleProPicSelect"
  ></CompProblemPicSelect>
  <CompProblemPicSelect
    v-if="pics.length > 1"
    title="整改图片"
    v-model:dialog-visible="changeDialog"
    mode="change"
    :pics="pics[1].path"
    :defaultFile="[{ url: seletcedChangePic }]"
    @submit="handleChangePicSelect"
  ></CompProblemPicSelect>
</template>
<script setup>
import { ref, watch, computed } from 'vue';
import dayjs from 'dayjs';
import ProCheckProxy from '@/views/fysp/check/ProCheckProxy';
import unchangeImg from '@/assets/image/unchange.png';
 
import CompProblemPicSelect from './CompProblemPicSelect.vue';
 
const props = defineProps({
  problem: {
    type: Object,
    default: () => {
      return {};
    }
  },
  btnName: {
    type: String,
    default: '修改'
  }
});
 
const emit = defineEmits(['change']);
 
const pics = ref([]);
const proDialog = ref(false);
const seletcedProblemPic = ref();
const changeDialog = ref(false);
const seletcedChangePic = ref();
const problemDes = ref('');
const changeDes = ref('未整改');
 
const title = computed(() => {
  const time = dayjs(props.problem.time).format('M月');
  return `${time}现场问题及整改图片`;
});
 
function getPics() {
  pics.value = ProCheckProxy.proPics(props.problem);
  if (pics.value[0].path.length > 0) {
    seletcedProblemPic.value = pics.value[0].path[0];
  }
  if (pics.value[1].path.length > 0) {
    seletcedChangePic.value = pics.value[1].path[0];
  }
}
 
function handleProPicSelect(imgList) {
  if (imgList && imgList.length > 0) {
    seletcedProblemPic.value = imgList[0].url;
    onChange();
  }
}
 
function handleChangePicSelect(imgList) {
  if (imgList && imgList.length > 0) {
    seletcedChangePic.value = imgList[0].url;
    onChange();
  }
}
 
function onChange() {
  const value = {
    proPic: seletcedProblemPic.value,
    changePic: seletcedChangePic.value ? seletcedChangePic.value : unchangeImg,
    location: props.problem.location,
    problemDes,
    changeDes
  };
  emit('change', value);
}
 
watch(
  () => props.problem,
  (nV, oV) => {
    if (nV != oV) {
      getPics();
      problemDes.value = nV.problemname;
      changeDes.value = nV.ischanged ? '已整改' : '未整改';
      
      onChange();
    }
  },
  { immediate: true }
);
 
watch(problemDes, (nV, oV) => {
  if (nV != oV) {
    onChange();
  }
});
watch(changeDes, (nV, oV) => {
  if (nV != oV) {
    onChange();
  }
});
</script>
<style scoped>
.image {
  width: 200px;
  height: 210px;
  border-radius: 4px;
}
 
table {
  color: #333333;
  border-color: #666666;
  border-collapse: collapse;
}
 
tr {
  font-size: var(--el-font-size-small);
}
 
td {
  border: 1px solid black;
  padding: 2px 6px;
  /* border-width: 1px;
  padding: 8px;
  border-style: solid;
  border-color: #666666; */
}
 
.pop-button {
  position: absolute;
  bottom: 0;
  right: 0;
}
 
.image-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background: var(--el-fill-color-light);
}
</style>