华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1828 lines
70 KiB

  1. <template>
  2. <div class="flex " :class="getFlexClass()">
  3. <div class="flex" :class="getFlexClass()">
  4. <el-input v-if="type === 'input'" :maxlength="item.maxlength || 50" :disabled="getDisabled()"
  5. :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" @blur="onBlur"
  6. :placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" />
  7. <el-input v-else-if="type === 'textarea'" :maxlength="item.maxlength || 50" :disabled="getDisabled()"
  8. :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" type="textarea" show-word-limit
  9. resize="none" @blur="onBlur" :rows="item.rows || 3" :placeholder="getPlaceholder()" v-model="inputValue"
  10. @input="onInputChange" @change="onInputChange" />
  11. <DecimalInput v-else-if="type === 'inputNumber'" @blur="onCommonHandleSaveRecord"
  12. :maxlength="item.maxlength || 10" class="flex1" :disabled="getDisabled()"
  13. :controls="item.controls || false" :min="item.min || 0" :prepend="item.prepend"
  14. :decimalDigits="getDecimalDigits()" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"
  15. :placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" />
  16. <el-select v-else-if="type === 'select'" class="flex1" :multiple="item.multiple"
  17. :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue"
  18. :disabled="getDisabled()" :placeholder="getPlaceholder()" @remove-tag="onRemoveTag"
  19. @visible-change="onSelectBlur" @change="onInputChange" filterable>
  20. <el-option v-for="op in item.options" :key="op.value" :label="op.label" :value="op.value">
  21. </el-option>
  22. </el-select>
  23. <el-checkbox v-else-if="type === 'checkbox'" class="flex1" :multiple="item.multiple"
  24. :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue"
  25. :disabled="getDisabled()" :placeholder="getPlaceholder()" @change="onItemCheckboxChange">
  26. {{ item.checkboxLabel }}
  27. </el-checkbox>
  28. <el-radio-group v-else-if="type === 'radio'" v-model="inputValue"
  29. :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" :disabled="getDisabled()"
  30. @change="onItemCheckboxChange">
  31. <el-radio v-for="option in item.options" :key="option.value" :label="option.value"
  32. :disabled="getDisabled()">
  33. {{ option.label }}
  34. </el-radio>
  35. </el-radio-group>
  36. <div v-else-if="type === 'checkboxList'" class="flex1 checkbox-list-container"
  37. :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')">
  38. <el-checkbox-group v-model="checkboxListValue.checkboxValues" @change="onCheckboxListChange">
  39. <div v-for="option in item.options" :key="option.value" class="checkbox-item">
  40. <el-checkbox :label="option.value" :disabled="getDisabled()">
  41. {{ option.label }}
  42. </el-checkbox>
  43. <div v-if="isShowCheckboxListOther(option)">
  44. <el-input v-model="checkboxListValue.otherValues[option.otherCode]"
  45. :class="{ 'error-border': isOtherInputError(option.otherCode) }"
  46. :placeholder="option.otherPlaceholder || '请输入'" @blur="onCheckboxListOtherBlur($event, option.otherCode)"/>
  47. </div>
  48. </div>
  49. </el-checkbox-group>
  50. </div>
  51. <el-date-picker v-else-if="type === 'dateTime'" type="datetime" class="flex1"
  52. :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue"
  53. :disabled="getDisabled()" format="yyyy/MM/dd HH:mm:ss" :placeholder="getPlaceholder()"
  54. @change="(val) => onDateChange(val, 'yyyy/MM/DD HH:mm:ss')">
  55. </el-date-picker>
  56. <el-date-picker v-else-if="type === 'datePicker'" class="flex1"
  57. :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue"
  58. :disabled="getDisabled()" format="yyyy/MM/dd" :placeholder="getPlaceholder()"
  59. @change="(val) => onDateChange(val, 'yyyy/MM/DD')">
  60. </el-date-picker>
  61. <el-button v-else-if="type === 'button'" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"
  62. :disabled="getDisabled()" type="primary" @click="handleClickButton(item)">
  63. {{ $t(item.buttonName) }}
  64. <input type="hidden" v-model="inputValue">
  65. </el-button>
  66. <div class="clickable"
  67. :class="getFillTypeStyle() + (getDisabled() ? ' disabled' : '') + (orangeBg ? ' orange-bg' : '')"
  68. v-else-if="item.type === 'clickable'" @click="handleClickable(item, $event)">
  69. <span v-if="inputValue">{{ inputValue }}</span>
  70. <span v-else class="default-placeholder-text">{{ getPlaceholder() }}</span>
  71. </div>
  72. <div class="clickable"
  73. :class="getFillTypeStyle() + (getDisabled() ? ' disabled' : '') + (orangeBg ? ' orange-bg' : '')"
  74. v-else-if="regentType.includes(item.type)" @click="onCommonHandleRegent(item, item.type)">
  75. <span v-if="inputValue">{{ inputValue }}</span>
  76. <span v-else class="default-placeholder-text">{{ getPlaceholder() }}</span>
  77. </div>
  78. <template v-else-if="type === 'attachment'">
  79. <el-upload ref="uploadRef" class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview"
  80. :headers="headers" :before-remove="beforeRemove" :on-remove="handleRemove" multiple :limit="10"
  81. :on-success="handleSuccess" :on-change="handleChange" :on-exceed="handleExceed"
  82. :file-list="fileList" :auto-upload="false">
  83. <el-button :disabled="getDisabled()" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"
  84. size="small" type="primary">点击上传</el-button>
  85. <span v-if="error" class="atta-tips">请上传附件</span>
  86. <div slot="tip" class="el-upload__tip">支持扩展名.rar .zip .doc .docx .pdf .jpg文件大小不超过2MB</div>
  87. </el-upload>
  88. </template>
  89. <div v-else-if="type === 'checkboxTag'" class="flex1 checkbox-tag-wrapper" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')">
  90. <div v-for="(tag, tagIndex) in checkboxTagList" :key="tagIndex" class="checkbox-tag-container">
  91. <div class="checkbox-tag-item">
  92. <el-checkbox v-model="tag.checked" :disabled="getDisabled()"
  93. @change="onCheckboxTagChange(tagIndex, $event)"></el-checkbox>
  94. <div class="tag-content blue-border">
  95. <el-input v-if="templateFillType === 'preFill'" v-model="tag.tagValue"
  96. :ref="'tagInput_' + tagIndex" :maxlength="item.maxlength || 20"
  97. @blur="onTagBlur(tagIndex)" @keyup.enter.native="onTagBlur(tagIndex)"
  98. placeholder="请输入" size="mini" class="tag-input" />
  99. <el-tag v-else :type="'info'" class="tag-display" :closable="false">
  100. {{ tag.tagValue }}
  101. </el-tag>
  102. <el-popconfirm confirm-button-text='确认' cancel-button-text='取消' icon="el-icon-info"
  103. icon-color="red" title="确认删除当前编号?" @confirm="onDeleteTag(tagIndex)">
  104. <i slot="reference" v-if="templateFillType === 'preFill'"
  105. class="el-icon-close delete-icon"></i>
  106. </el-popconfirm>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. <div v-else-if="type === 'fqyq'" :class="getFillTypeStyle()">
  112. <el-radio-group v-model="fqyqValue.mainRadio" :disabled="getDisabled()" @input="onFqyqRadioChange($event,'mainRadio')">
  113. <div class="item-center mb-10">
  114. <el-radio label="是"></el-radio>
  115. <div class="item-center" v-if="fqyqValue.mainRadio === '是'">
  116. <el-input class="fqyq-input" maxlength="100" v-model="fqyqValue.inputValue" :disabled="getDisabled()" placeholder="请输入" @blur="onFqyqInputBlur" ></el-input>
  117. <div class="fs-14 mr-10">是否在规定时间完成</div>
  118. <el-radio-group v-model="fqyqValue.subRadio" :disabled="getDisabled()" @input="onFqyqRadioChange($event,'subRadio')">
  119. <el-radio label="是"></el-radio>
  120. <el-radio label="否"></el-radio>
  121. </el-radio-group>
  122. </div>
  123. </div>
  124. <el-radio label="否"></el-radio>
  125. </el-radio-group>
  126. </div>
  127. </div>
  128. <div class="handle-row" v-if="isShowHandle()">
  129. <el-checkbox v-model="checkboxValue" v-if="getIsShowCheckboxIcon()" :disabled="getCheckboxDisabled()"
  130. class="mr-5" @change="onCheckboxChange"></el-checkbox>
  131. <div class="handle-icon" v-if="getIsShowQuestionIcon()" @click="onClickQuestion"
  132. @mouseenter="(e) => onMouseEnter('replyRecord', e)" @mouseleave="onMouseLeave">
  133. <Question :class="getQuestionColor()" />
  134. </div>
  135. <img v-if="getIsShowCopyIcon()" @click="onCopy" src="@/assets/images/copy-icon.svg" class="handle-icon"
  136. alt="" />
  137. <img v-if="getIsShowRecordIcon()" @mouseenter="(e) => onMouseEnter('fieldChanged', e)"
  138. @mouseleave="onMouseLeave" src="@/assets/images/record-icon.svg" class="handle-icon" alt="" />
  139. </div>
  140. <!-- 修改记录模态框 -->
  141. <div v-if="showModal && modificationRecords.length > 0" ref="modalRef"
  142. :class="['modification-modal', { 'show': showModal }]" @mouseenter="onModalEnter"
  143. @mouseleave="onModalLeave">
  144. <div class="modal-content">
  145. <div class="records-list">
  146. <div v-for="(record, index) in modificationRecords" :key="index" class="record-item">
  147. <!-- 字段修改记录 -->
  148. <div class="record-row" v-if="currentRecordType === 'fieldChanged'">
  149. <div>
  150. <span>{{ index + 1 }}.</span>
  151. <span> {{ getUserName(record) }} </span>
  152. <span>{{ record.time }} </span>
  153. <span>{{ modificationRecords.length - 1 == index ? "提交" : "修改" }}</span>
  154. </div>
  155. <div v-if="modificationRecords.length - 1 !== index">
  156. <div>原值{{ record.oldValue }}</div>
  157. <div>修改值{{ record.value }}</div>
  158. <div v-if="record.reason">备注{{ record.reason }}</div>
  159. </div>
  160. </div>
  161. <!-- 回复记录 -->
  162. <div class="record-row" v-if="currentRecordType === 'replyRecord'">
  163. <div>
  164. <span> {{ getUserName(record) }} </span>
  165. <span>{{ record.time }} </span>
  166. </div>
  167. <div>
  168. <div v-if="record.content">复核意见{{ record.content }}</div>
  169. <div v-if="record.reply">回复意见{{ record.reply }}</div>
  170. </div>
  171. </div>
  172. <hr v-if="index < modificationRecords.length - 1">
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. <el-dialog :close-on-click-modal="false" append-to-body :title="templateFillType == 'actFill' ? '回复意见' : '复核意见'"
  178. :visible.sync="visible" width="30%">
  179. <el-input v-model="replyContent" type="textarea" show-word-limit resize="none" rows="8" placeholder="输入内容"
  180. maxlength="500" />
  181. <span slot="footer" class="dialog-footer">
  182. <el-button @click="visible = false"> </el-button>
  183. <el-button type="primary" @click="onReplyConfirm"> </el-button>
  184. </span>
  185. </el-dialog>
  186. </div>
  187. </template>
  188. <script>
  189. import Question from "./icons/Question.vue";
  190. import DecimalInput from "./DecimalInput.vue";
  191. import { EventBus } from "@/utils/eventBus";
  192. import moment from "moment";
  193. import { deepClone } from "@/utils/index";
  194. import { getuuid } from "@/utils/index.js";
  195. import { getToken } from "@/utils/auth"
  196. import { isValueEmpty } from '@/utils/index.js';
  197. export default {
  198. inject: ['templateData', 'templateFillType', "getZdxgjl", "getFhyjjl", "updateZdxgjl", "replaceFhyjjl", "updateFhyjjl", "getFieldCheckObj", "updateFieldCheckObj"],
  199. components: {
  200. Question,
  201. DecimalInput,
  202. },
  203. props: {
  204. type: {//form类型 input/select等
  205. type: String,
  206. default: "input"
  207. },
  208. item: {
  209. type: Object,
  210. default: () => {
  211. return {
  212. placeholder: "",
  213. maxlength: 30,
  214. label: "",
  215. disabled: false,
  216. }
  217. }
  218. },
  219. // v-model 值
  220. value: {
  221. type: [String, Number, Array, Boolean, Object],
  222. default: ''
  223. },
  224. // 错误状态
  225. error: {
  226. type: Boolean,
  227. default: false
  228. },
  229. // 橙色背景状态
  230. orangeBg: {
  231. type: Boolean,
  232. default: false
  233. },
  234. fieldKey: {
  235. type: String,
  236. default: ""
  237. },
  238. fieldItemLabel: {
  239. type: String,
  240. default: "",
  241. },
  242. //是否记录修改
  243. isFieldsRecord: {
  244. type: Boolean,
  245. default: true,
  246. },
  247. sourceFrom: {
  248. type: String,
  249. default: ""
  250. },
  251. },
  252. data() {
  253. let initialValue = this.value;
  254. let initialOtherValues = {}, checkboxTagList = [];
  255. if(this.type === 'checkboxList' && !this.value) {
  256. initialValue = {
  257. checkboxValues: [],
  258. otherValues: {}
  259. };
  260. } else if (this.type === 'checkboxTag' && Array.isArray(this.value)) {
  261. // checkboxTag类型,value是数组格式
  262. checkboxTagList = this.value.map(tag => ({
  263. checked: tag.checked,
  264. tagValue: tag.tagValue || ''
  265. }));
  266. } else if (this.type === 'fqyq' && !this.value) {
  267. initialValue = {mainRadio: '', subRadio: '',inputValue:""};
  268. }
  269. return {
  270. inputValue: initialValue,
  271. oldValue: initialValue, // 记录上一次的值
  272. showModal: false, // 控制模态框显示
  273. modificationRecords: [], // 存储修改记录
  274. modalTimer: null, // 用于延迟隐藏模态框
  275. isHoveringModal: false, // 是否悬停在模态框上
  276. isHoveringMain: false, // 是否悬停在主元素上(这个实际上不需要,因为我们有事件处理)
  277. currentRecordType: '', // 当前悬停的记录类型(replyRecord 或 modifyRecord)
  278. replyContent: '', // 回复内容
  279. visible: false,//是否显示弹窗
  280. checkboxValue: this.getChecked(),//是否选中
  281. checkboxTagList: checkboxTagList, // checkboxTag类型的列表数据
  282. oldCheckboxTagList: JSON.parse(JSON.stringify(checkboxTagList)), // 记录上一次的checkboxTagList
  283. fqyqValue: initialValue, // fqyq类型的值
  284. oldFqyqValue: {...initialValue}, // 记录上一次的fqyq值
  285. checkboxListValue: initialValue, // checkboxList类型的值
  286. oldCheckboxListValue: JSON.parse(JSON.stringify(initialValue)), // 记录上一次的checkboxList值
  287. uuid: getuuid(), // 唯一标识符,用于EventBus事件匹配
  288. regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], //试剂/仪器/供试品等类型
  289. selectRegentInfo: {},//选择的试剂/仪器/供试品等信息
  290. fileList: [],//上传的文件列表
  291. uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload",
  292. headers: {
  293. Authorization: "Bearer " + getToken(),
  294. },
  295. pendingUploadFile: null, // 用于存储待上传的文件
  296. pendingRemoveFile: null, // 用于存储待删除的文件
  297. currentTagIndex:-1,//当前选中的checkboxTag索引
  298. currentHandleType:'',//当前操作的类型
  299. currentOtherCode:'',//当前操作的otherCode
  300. }
  301. },
  302. watch: {
  303. value(newVal) {
  304. if (this.type === 'checkboxList' && newVal && typeof newVal === 'object') {
  305. this.checkboxListValue = JSON.parse(JSON.stringify(newVal));
  306. } else if (this.type === 'checkboxTag' && Array.isArray(newVal)) {
  307. // checkboxTag类型,value是数组格式
  308. this.checkboxTagList = newVal.map(tag => ({
  309. checked: tag.checked,
  310. tagValue: tag.tagValue || ''
  311. }));
  312. } else if (this.type === 'fqyq' && newVal && typeof newVal === 'object') {
  313. // fqyq类型
  314. this.fqyqValue = {
  315. mainRadio: newVal.mainRadio || '',
  316. inputValue: newVal.inputValue || '',
  317. subRadio: newVal.subRadio || ''
  318. };
  319. } else {
  320. this.inputValue = newVal;
  321. }
  322. }
  323. },
  324. filters: {
  325. },
  326. mounted() {
  327. if (this.item.type === 'attachment') {
  328. try {
  329. this.fileList = JSON.parse(this.value);
  330. } catch (e) {
  331. this.fileList = [];
  332. }
  333. }
  334. EventBus.$on('onExternalFieldUpdate', this.handleExternalFieldUpdate);
  335. EventBus.$on('onEditSignCancel', this.handleEditSignCancel);
  336. EventBus.$on('onEditSignCallback', this.handleEditSignCallback);
  337. //试剂
  338. EventBus.$on("onReagentSubmit", this.onReagentSubmit)
  339. //仪器
  340. EventBus.$on("onInstrumentSubmit", this.onMixReagentSubmit)
  341. //供试品/试剂/给药制剂等
  342. EventBus.$on("onMixReagentSubmit", this.onMixReagentSubmit)
  343. },
  344. unmounted() {
  345. EventBus.$off('onExternalFieldUpdate', this.handleExternalFieldUpdate);
  346. EventBus.$off('onEditSignCancel', this.handleEditSignCancel);
  347. EventBus.$off('onEditSignCallback', this.handleEditSignCallback);
  348. EventBus.$off("onReagentSubmit", this.onReagentSubmit)
  349. EventBus.$off("onInstrumentSubmit", this.onMixReagentSubmit)
  350. EventBus.$off("onMixReagentSubmit", this.onMixReagentSubmit)
  351. },
  352. methods: {
  353. getFlexClass() {
  354. const noFlexArr = ["radio", "checkboxTag","fqyq"]
  355. return noFlexArr.includes(this.type) ? '' : 'flex1'
  356. },
  357. getDecimalDigits() {
  358. const { precision } = this.item;
  359. if (!isNaN(precision)) {
  360. return precision
  361. }
  362. return 6
  363. },
  364. onInstrumentSubmit(data) {
  365. if (data.uuid !== this.uuid) return;
  366. this.selectRegentInfo = data;
  367. },
  368. // 文件状态改变时的钩子,添加文件、上传成功、上传失败时都会被调用
  369. handleChange(file, fileList) {
  370. // 如果是新添加的文件(status为ready),进行验证
  371. if (file.status === 'ready') {
  372. const isAllowedType = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf',
  373. 'application/x-rar-compressed', 'application/zip',
  374. 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'].includes(file.raw.type)
  375. const isLt2M = file.size / 1024 / 1024 < 2
  376. if (!isAllowedType) {
  377. this.$message.error(`文件 ${file.name} 格式不支持!只能上传 JPG/PNG/GIF/PDF/RAR/ZIP/DOC/DOCX 格式的文件`)
  378. // 从fileList中移除该文件
  379. const index = fileList.indexOf(file);
  380. if (index > -1) {
  381. fileList.splice(index, 1);
  382. }
  383. this.fileList = [...fileList];
  384. return
  385. }
  386. if (!isLt2M) {
  387. this.$message.error(`文件 ${file.name} 大小超过2MB!`)
  388. // 从fileList中移除该文件
  389. const index = fileList.indexOf(file);
  390. if (index > -1) {
  391. fileList.splice(index, 1);
  392. }
  393. this.fileList = [...fileList];
  394. return
  395. }
  396. // 如果已经有文件在列表中(不包括当前新添加的),需要验证电子签名
  397. const existingFiles = fileList.filter(f => f !== file && f.status === 'success');
  398. if (existingFiles.length > 0) {
  399. // 保存待上传的文件信息
  400. this.pendingUploadFile = file;
  401. // 从fileList中暂时移除新文件,等待签名验证
  402. const index = fileList.indexOf(file);
  403. if (index > -1) {
  404. fileList.splice(index, 1);
  405. }
  406. this.fileList = [...fileList];
  407. // 触发电子签名弹窗
  408. EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
  409. return;
  410. }
  411. // 没有现有文件或验证通过,手动提交上传
  412. this.$nextTick(() => {
  413. // 找到对应的upload组件并提交
  414. const uploadComponent = this.$refs.uploadRef;
  415. if (uploadComponent) {
  416. uploadComponent.submit();
  417. }
  418. });
  419. }
  420. // 更新fileList
  421. this.fileList = fileList;
  422. },
  423. handleSuccess(res, file, fileList) {
  424. if (res.code == 200) {
  425. this.fileList = fileList;
  426. // 更新inputValue为文件路径列表,方便后续保存
  427. this.inputValue = JSON.stringify(this.getFileList(fileList));
  428. this.$emit("change", this.inputValue)
  429. this.onCommonHandleSaveRecord();
  430. this.$message.success('文件上传成功');
  431. } else {
  432. this.$message.error(res.message || '文件上传失败');
  433. // 上传失败,从列表中移除
  434. const index = fileList.indexOf(file);
  435. if (index > -1) {
  436. fileList.splice(index, 1);
  437. this.fileList = [...fileList];
  438. }
  439. }
  440. },
  441. getFileList(fileList) {
  442. const list = [];
  443. fileList.forEach(item => {
  444. const o = { name: item.name };
  445. if (item.url) {//回填的数据
  446. o.url = item.url
  447. } else {//新上传的
  448. o.url = item.response.data.url
  449. }
  450. list.push(o)
  451. })
  452. return list;
  453. },
  454. // 删除前验证电子签名
  455. beforeRemove(file) {
  456. // 所有删除操作都需要验证电子签名
  457. // 保存待删除的文件信息
  458. this.pendingRemoveFile = { file, fileList: this.fileList };
  459. // 触发电子签名弹窗
  460. EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
  461. // 返回false阻止默认删除行为,等待签名验证通过后再删除
  462. return false;
  463. },
  464. handleRemove(file, fileList) {
  465. // on-remove事件在before-remove返回false时不会触发
  466. // 这个方法在签名验证通过后通过executeRemove调用
  467. // 这里不需要额外处理,因为executeRemove已经处理了删除逻辑
  468. },
  469. // 执行实际的文件删除操作
  470. executeRemove(file, fileList) {
  471. // 从el-upload的内部uploadFiles中移除文件
  472. const uploadComponent = this.$refs.uploadRef;
  473. if (uploadComponent && uploadComponent.uploadFiles) {
  474. const uploadFileIndex = uploadComponent.uploadFiles.indexOf(file);
  475. if (uploadFileIndex > -1) {
  476. uploadComponent.uploadFiles.splice(uploadFileIndex, 1);
  477. }
  478. }
  479. // 从fileList中移除文件
  480. const index = fileList.indexOf(file);
  481. if (index > -1) {
  482. fileList.splice(index, 1);
  483. }
  484. // 更新fileList
  485. this.fileList = [...fileList];
  486. // 更新inputValue为剩余文件路径列表
  487. this.inputValue = JSON.stringify(this.getFileList(fileList));
  488. this.$emit("change", this.inputValue);
  489. // 触发保存记录
  490. this.onCommonHandleSaveRecord();
  491. this.$message.success(`文件 ${file.name} 已移除`);
  492. },
  493. handlePreview(file) {
  494. console.log(file)
  495. const url = file.url || file.response?.data?.url;
  496. if (url) {
  497. window.open(process.env.VUE_APP_FILE_DOMAIN + url, '_blank');
  498. }
  499. },
  500. handleExceed(files, fileList) {
  501. this.$message.warning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
  502. },
  503. //试剂弹窗提交
  504. onMixReagentSubmit(data) {
  505. if (data.uuid !== this.uuid) return;
  506. // 创建一个验证控制器,用于收集各级验证结果
  507. const validationController = {
  508. isPrevented: false,
  509. errorMsg: '',
  510. prevent(msg) {
  511. this.isPrevented = true;
  512. if (msg) this.errorMsg = msg;
  513. }
  514. };
  515. // 触发自定义验证事件,让父组件判断是否满足需求
  516. // 父组件可以通过validationController.prevent(msg)来阻止提交
  517. this.$emit('beforeReagentSubmit', data, validationController);
  518. // 检查是否被阻止
  519. if (validationController.isPrevented) {
  520. // 验证不通过,显示错误信息
  521. if (validationController.errorMsg) {
  522. this.$message.error(validationController.errorMsg);
  523. }
  524. return;
  525. }
  526. // 验证通过,继续执行
  527. this.executeReagentSubmit(data);
  528. },
  529. // 执行试剂提交的共同逻辑
  530. executeReagentSubmit(data) {
  531. this.inputValue = data.selectedId;
  532. const { filledCodes = [] } = this.item;
  533. console.log(filledCodes, "filledCodes")
  534. const { selectInfo, row } = data;
  535. if (filledCodes.length > 0) {
  536. this.inputValue = row[filledCodes[0]] + "(" + row[filledCodes[1]] + ")";
  537. }
  538. this.selectRegentInfo = data;
  539. EventBus.$emit("hideSelectMixReagentDialog");
  540. this.onCommonHandleSaveRecord(this.inputValue);
  541. },
  542. //统一处理试剂/供试品等弹窗
  543. onCommonHandleRegent(item, type) {
  544. if (this.templateFillType !== 'actFill') {
  545. return
  546. }
  547. let params = {
  548. studyFormId: this.templateData.id,
  549. uuid: this.uuid,
  550. sourceFrom: this.sourceFrom,
  551. }
  552. let eventName = "showSelectMixReagentDialog";
  553. if (type === "yq") {
  554. eventName = "showSelectInstrumentDialog";
  555. } else {
  556. const sjType = {
  557. sj: "1",//试剂
  558. gsp: "7",//供试品
  559. mix: "1",//试剂/供试品/试剂
  560. gyzj: "3",//给药制剂
  561. mjy: "5",//麻精药
  562. xj: "9",//细菌
  563. xb: "11",//细胞
  564. jcb: "13",//检测板
  565. qxbd: "15",//前序表单
  566. }
  567. params = {
  568. ...params,
  569. type: sjType[type]
  570. };
  571. if (type === "mix") {
  572. params.mixType = true;
  573. }
  574. }
  575. EventBus.$emit(eventName, params)
  576. // this.$emit('regent', item,type);
  577. },
  578. // 点击按钮
  579. handleClickButton(item) {
  580. this.inputValue = `button-${new Date().getTime()}`;
  581. this.onCommonHandleSaveRecord(this.inputValue);
  582. },
  583. onDateChange(val, format) {
  584. this.inputValue = moment(val).format(format);
  585. this.onCommonHandleSaveRecord(this.inputValue);
  586. },
  587. getUserName(record) {
  588. const locale = this.$i18n.locale;
  589. if (locale === 'zh_CN') {
  590. return record.userNameCn;
  591. }
  592. return record.userNameEn;
  593. },
  594. // 处理电子签名取消事件
  595. handleEditSignCancel(data) {
  596. if (data.uuid === this.uuid) {
  597. // 如果有待上传的文件,清空它
  598. if (this.pendingUploadFile) {
  599. this.pendingUploadFile = null;
  600. this.$message.info('已取消文件上传');
  601. } else if (this.pendingRemoveFile) {
  602. // 如果有待删除的文件,清空它
  603. this.pendingRemoveFile = null;
  604. this.$message.info('已取消文件删除');
  605. } else {
  606. this.resetRecord();
  607. }
  608. }
  609. },
  610. // 处理电子签名确认回调事件
  611. handleEditSignCallback(data) {
  612. if (data.uuid === this.uuid) {
  613. this.onEditSignSave(data.data);
  614. }
  615. },
  616. onEditSignSave(data) {
  617. // 检查是否有待上传的文件
  618. if (this.pendingUploadFile) {
  619. // 签名验证通过,将文件添加到列表并上传
  620. const file = this.pendingUploadFile;
  621. // 将文件添加到 fileList
  622. this.fileList.push(file);
  623. // 清空待上传文件标记
  624. this.pendingUploadFile = null;
  625. // 手动触发上传
  626. this.$nextTick(() => {
  627. const uploadComponent = this.$refs.uploadRef;
  628. if (uploadComponent) {
  629. uploadComponent.submit();
  630. }
  631. });
  632. } else if (this.pendingRemoveFile) {
  633. // 签名验证通过,执行文件删除
  634. const { file, fileList } = this.pendingRemoveFile;
  635. // 清空待删除文件标记
  636. this.pendingRemoveFile = null;
  637. // 执行删除操作
  638. this.executeRemove(file, fileList);
  639. } else {
  640. // 没有待上传/删除文件,执行正常的记录更新
  641. this.handleUpdateRecord(data);
  642. }
  643. },
  644. getChecked() {
  645. return !!this.getFieldCheckObj()[this.fieldKey]?.checked;
  646. },
  647. getFillTypeStyle(type) {
  648. const { fillType } = this.item;
  649. const filterType = ["attachment","checkboxTag","fqyq"]
  650. const typeObj = {
  651. actFill: "orange-border",//实际填写的边框颜色
  652. green: "green-border",
  653. preFill: "blue-border",//预填写的边框颜色
  654. }
  655. // 如果有错误状态,返回红色边框样式,覆盖原有的边框颜色
  656. if (this.error && !filterType.includes(this.type)) {
  657. return "error-border";
  658. }
  659. return typeObj[fillType] || ""
  660. },
  661. //确认回复
  662. onReplyConfirm() {
  663. if (!this.replyContent) {
  664. this.$message({
  665. message: '请输入内容',
  666. type: 'error'
  667. });
  668. return;
  669. }
  670. const baseInfo = this.getCommonRecordInfo();
  671. const record = {
  672. ...baseInfo,
  673. title: this.templateFillType == 'actFill' ? "回复意见" : "复核意见",
  674. time: moment().format("YYYY-MM-DD HH:mm:ss"),
  675. }
  676. if (this.templateFillType == 'actFill') {
  677. record.reply = this.replyContent;
  678. const deepList = deepClone(this.getFhyjjl());//实际填报应该是修改指定的字段
  679. const item = deepList.find(o => o.key == record.key);
  680. if (item) {
  681. item.reply = this.replyContent;
  682. }
  683. this.replaceFhyjjl(deepList);//实际填报应该是修改指定的字段
  684. } else {
  685. const records = this.getReplyRecords();
  686. record.content = this.replyContent;
  687. if (records.length > 0) {
  688. const o = records[0];
  689. if (o.reply && o.content) {//如果填报人员已回复,那么就产生一条新的记录。
  690. this.updateFhyjjl(record);//qc直接插入数据源
  691. } else {//如果填报人员未填报,只更新当条记录的复核内容
  692. const deepList = deepClone(this.getFhyjjl());
  693. const item = deepList.find(it => it.key == record.key);
  694. if (item) {
  695. item.content = this.replyContent;
  696. }
  697. this.replaceFhyjjl(deepList);
  698. }
  699. } else {
  700. this.updateFhyjjl(record);//qc直接插入数据源
  701. }
  702. }
  703. const params = {
  704. //reply:回复,content:复核
  705. type: this.templateFillType == 'actFill' ? "reply" : "content",
  706. newRecord: [record],
  707. resourceList: this.getFhyjjl(),
  708. }
  709. // 触发回复记录事件
  710. EventBus.$emit('onModifyRecord', params);
  711. // 清空回复内容
  712. this.replyContent = '';
  713. // 隐藏弹窗
  714. this.visible = false;
  715. },
  716. //获取question图标颜色
  717. getQuestionColor() {
  718. const records = this.getReplyRecords();
  719. if (records.length > 0) {
  720. const o = records[0];
  721. if (o.reply && o.content) {//有回复意见和复核意见
  722. return "green"
  723. } else if (o.content && !o.reply) {//只有复核意见
  724. return "orange"
  725. } else {
  726. return "gray"
  727. }
  728. } else {//没有回复记录
  729. return "gray"
  730. }
  731. },
  732. // 复选框变化处理
  733. onCheckboxChange(val) {
  734. //有提出意见就不能勾选
  735. if (this.templateFillType == 'qc' && this.getQuestionColor() === "orange") {
  736. this.checkboxValue = false;
  737. this.$message({
  738. message: '该表单还有质疑项未处理,无法勾选',
  739. type: 'error'
  740. });
  741. return;
  742. }
  743. this.checkboxValue = val;
  744. // 触发修改记录事件
  745. EventBus.$emit('onModifyRecord', {
  746. type: "checkbox",
  747. fieldCheckObj: JSON.stringify({ ...this.getFieldCheckObj(), [this.fieldKey]: { checked: val } }),//复选框状态对象
  748. });
  749. this.updateFieldCheckObj({ [this.fieldKey]: { checked: val } });
  750. // this.$emit('input', val);
  751. // this.$emit('change', val);
  752. },
  753. onRemoveTag(e) {
  754. this.onCommonHandleSaveRecord(this.inputValue);
  755. },
  756. onItemCheckboxChange() {
  757. this.onCommonHandleSaveRecord(this.inputValue);
  758. },
  759. // 下拉框失去焦点处理
  760. onSelectBlur(visible) {
  761. if (!visible) {
  762. this.onCommonHandleSaveRecord(this.inputValue);
  763. }
  764. },
  765. // 统一处理输入变化
  766. onInputChange(val) {
  767. let value = val !== undefined ? val : this.inputValue;
  768. this.$emit('input', value);
  769. this.$emit('change', value);
  770. // 根据输入值判断是否显示错误状态
  771. const isEmpty = isValueEmpty(value);
  772. if (this.error && !isEmpty) {
  773. this.$emit('update:error', false);
  774. } else if (!this.error && isEmpty) {
  775. this.$emit('update:error', true);
  776. }
  777. },
  778. // checkboxTag的checkbox变化处理
  779. onCheckboxTagChange(tagIndex, e) {
  780. this.currentTagIndex = tagIndex;
  781. this.checkboxTagList[tagIndex].checked = e;
  782. this.emitCheckboxTagValue();
  783. this.onCommonHandleSaveRecord();
  784. },
  785. // 检查是否显示显示checkboxList的其他输入框
  786. isShowCheckboxListOther(option) {
  787. const {checkboxValues } = this.checkboxListValue
  788. if (!checkboxValues) {
  789. return false;
  790. }
  791. return option.otherCode && checkboxValues.includes(option.value);
  792. },
  793. // checkboxList的checkbox变化处理
  794. onCheckboxListChange(val) {
  795. this.currentHandleType = 'checkboxListValue';
  796. this.checkboxListValue.checkboxValues = val;
  797. this.onCommonHandleSaveRecord();
  798. },
  799. // tag输入框失去焦点
  800. onTagBlur(tagIndex) {
  801. this.currentTagIndex = tagIndex;
  802. const value = this.checkboxTagList[tagIndex].tagValue;
  803. this.emitCheckboxTagValue();
  804. this.onCommonHandleSaveRecord(value);
  805. },
  806. // 删除tag
  807. onDeleteTag(tagIndex) {
  808. this.currentTagIndex = tagIndex;
  809. // 从列表中删除指定索引的tag
  810. this.emitCheckboxTagValue();
  811. this.$emit("deleteTag", tagIndex);
  812. },
  813. // 发送checkboxTag的值
  814. emitCheckboxTagValue() {
  815. // 发送整个数组
  816. this.$emit('input', [...this.checkboxTagList]);
  817. this.$emit('change', [...this.checkboxTagList]);
  818. },
  819. // fqyq 主radio变化处理
  820. onFqyqRadioChange(val, radioType) {
  821. this.fqyqValue[radioType] = val;
  822. this.currentHandleType = radioType;
  823. this.onCommonHandleSaveRecord();
  824. },
  825. // fqyq 输入框失去焦点
  826. onFqyqInputBlur(e) {
  827. this.fqyqValue.inputValue = e.target.value;
  828. this.currentHandleType = 'inputValue';
  829. this.onCommonHandleSaveRecord(this.fqyqValue.inputValue);
  830. },
  831. // 统一处理失去焦点事件
  832. onBlur(e) {
  833. this.onCommonHandleSaveRecord(e.target.value);
  834. },
  835. // checkboxList的其他输入框失去焦点处理
  836. onCheckboxListOtherBlur(e, otherCode) {
  837. this.currentHandleType = "checkboxListOther";
  838. this.currentOtherCode = otherCode;
  839. this.checkboxListValue.otherValues[otherCode] = e.target.value;
  840. this.onCommonHandleSaveRecord(e.target.value);
  841. },
  842. // 点击question图标
  843. onClickQuestion() {
  844. const { templateFillType } = this;
  845. if (templateFillType == 'actFill' || templateFillType == 'qc') {
  846. if (templateFillType == 'qc') {
  847. const field = this.getFieldCheckObj()[this.fieldKey];
  848. if (field && field.checked) {
  849. this.$message({
  850. message: '该字段已勾选复核框,请先取消勾选后再进行提交疑问',
  851. type: 'error'
  852. });
  853. return;
  854. }
  855. }
  856. const records = this.getReplyRecords();
  857. let content = "";
  858. if (records.length > 0) {
  859. const o = records[0];
  860. if (!o.reply && templateFillType == 'qc') {//如果填报人员没有回复,qc点击的时候需要回填上次填报的信息
  861. content = o.content;
  862. } else if (templateFillType == 'actFill') {//如果qc没有复核,填报点击的时候需要回填上次填报的信息
  863. content = o.reply;
  864. }
  865. }
  866. this.replyContent = content;
  867. this.visible = true;
  868. }
  869. },
  870. getCheckboxListInfo(){
  871. const { otherValues,checkboxValues } = this.checkboxListValue;
  872. const { otherValues: oldOtherValues,checkboxValues: oldCheckboxValues } = this.oldCheckboxListValue;
  873. const o = {
  874. "checkboxListValue":{oldValue:oldCheckboxValues,newValue:checkboxValues,des:""},
  875. "checkboxListOther":{oldValue:oldOtherValues[this.currentOtherCode],newValue:otherValues[this.currentOtherCode],des:"样品信息:"},
  876. }
  877. return o[this.currentHandleType];
  878. },
  879. getFqyqInfo(){
  880. const { mainRadio,inputValue,subRadio } = this.fqyqValue;
  881. const { mainRadio: oldMainRadio,inputValue: oldInputValue,subRadio: oldSubRadio } = this.oldFqyqValue;
  882. const o ={
  883. "mainRadio":{oldValue:oldMainRadio,newValue:mainRadio,des:""},
  884. "inputValue":{oldValue:oldInputValue,newValue:inputValue,des:""},
  885. "subRadio":{oldValue:oldSubRadio,newValue:subRadio,des:"是否在规定时间完成:"}
  886. }
  887. return o[this.currentHandleType];
  888. },
  889. async onCommonHandleSaveRecord(val) {
  890. const isEmpty = isValueEmpty(this.inputValue);
  891. if (this.error && !isEmpty) {
  892. this.$emit('update:error', false);
  893. } else if (!this.error && isEmpty) {
  894. this.$emit('update:error', true);
  895. }
  896. // 创建验证控制器,让父组件可以在保存前进行验证
  897. const validationController = {
  898. isPrevented: false,
  899. errorMsg: '',
  900. prevent(msg) {
  901. this.isPrevented = true;
  902. if (msg) this.errorMsg = msg;
  903. }
  904. };
  905. // 触发beforeSaveRecord事件,让父组件进行验证
  906. this.$emit('beforeSaveRecord', {
  907. value: this.inputValue,
  908. oldValue: this.oldValue,
  909. fieldKey: this.fieldKey
  910. }, validationController);
  911. // 检查是否被阻止
  912. if (validationController.isPrevented) {
  913. // 验证不通过,显示错误信息
  914. if (validationController.errorMsg) {
  915. this.$message.error(validationController.errorMsg);
  916. }
  917. // 回退到旧值
  918. this.inputValue = this.oldValue;
  919. this.$emit('input', this.inputValue);
  920. return;
  921. }
  922. if (!this.isFieldsRecord) {//是否需要记录修改记录
  923. this.$emit("blur", this.inputValue);
  924. this.$emit('input', this.inputValue);
  925. this.$emit("change", this.inputValue);
  926. return;
  927. }
  928. // 值发生了变化,需要弹出密码输入框
  929. let isSame = true, isOldValueEmpty = true;
  930. const { currentHandleType } = this;
  931. // 如果是checkboxList类型,需要同时比较otherValues
  932. if (this.type === 'checkboxList') {
  933. const current = this.getCheckboxListInfo();
  934. isSame = this.isEqual(current.oldValue,current.newValue);
  935. isOldValueEmpty = isValueEmpty(current.oldValue);
  936. } else if (this.type === "checkboxTag") {
  937. // checkboxTag类型,只比较当前tagIndex的数据
  938. const currentTag = this.checkboxTagList[this.currentTagIndex];
  939. const oldTag = this.oldCheckboxTagList[this.currentTagIndex] || {};
  940. isSame = this.isEqual(oldTag.checked, currentTag.checked);
  941. isOldValueEmpty = isValueEmpty(oldTag.checked);
  942. } else if (this.type === "fqyq") {
  943. const current = this.getFqyqInfo();
  944. isSame = this.isEqual(current.oldValue,current.newValue);
  945. isOldValueEmpty = isValueEmpty(current.oldValue);
  946. } else {
  947. isSame = this.isEqual(this.oldValue, this.inputValue)
  948. isOldValueEmpty = isValueEmpty(this.oldValue);
  949. }
  950. console.log(isSame,isOldValueEmpty,this.fqyqValue,this.oldFqyqValue,"isSame")
  951. if (isSame) {
  952. return;
  953. }
  954. if (!isOldValueEmpty && !(isSame) && this.templateFillType === "actFill") {
  955. // 通过EventBus触发电子签名弹窗
  956. EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
  957. } else {//如果是第一次填写,不需要密码验证
  958. this.handleUpdateRecord()
  959. }
  960. },
  961. //如果用户取消,那么回退到上一次的值
  962. resetRecord() {
  963. // 用户点击取消,还原数据
  964. let oldValue = this.oldValue;
  965. if (this.type === 'checkboxList') {
  966. oldValue = {
  967. checkboxValues: this.oldCheckboxListValue.checkboxValues,
  968. otherValues: this.oldCheckboxListValue.otherValues
  969. };
  970. } else if (this.type === "checkboxTag") {
  971. // checkboxTag类型,只回退当前tagIndex的数据
  972. if (this.currentTagIndex >= 0 && this.currentTagIndex < this.oldCheckboxTagList.length) {
  973. const oldTag = this.oldCheckboxTagList[this.currentTagIndex];
  974. this.checkboxTagList[this.currentTagIndex] = { ...oldTag };
  975. oldValue = [...this.checkboxTagList];
  976. } else {
  977. // 如果没有指定tagIndex,回退整个数组
  978. this.checkboxTagList = JSON.parse(JSON.stringify(this.oldCheckboxTagList));
  979. oldValue = [...this.checkboxTagList];
  980. }
  981. } else if (this.type === "fqyq") {
  982. // 如果没有指定字段,回退整个对象
  983. this.fqyqValue = JSON.parse(JSON.stringify(this.oldFqyqValue));
  984. oldValue = { ...this.fqyqValue };
  985. }
  986. this.inputValue = this.oldValue;
  987. this.$emit('input', oldValue); // 触发 v-model 更新
  988. // this.$emit("blur", this.oldValue);
  989. this.$emit("change", oldValue, "cancel");
  990. if (this.item.type === "clickable") {
  991. this.$emit("resetRecord");
  992. }
  993. },
  994. //处理更新记录
  995. handleUpdateRecord(data, recordData) {
  996. const baseInfo = this.getCommonRecordInfo();
  997. if (!this.oldValue && !this.inputValue) {
  998. return
  999. }
  1000. if (recordData) {
  1001. this.oldValue = recordData.oldValue;
  1002. this.inputValue = recordData.inputValue;
  1003. }
  1004. let recordOldVlaue = this.oldValue, recordValue = this.inputValue, isModify = !!this.oldValue;
  1005. if (this.type === "checkboxTag") {
  1006. // checkboxTag类型,只记录当前tagIndex的数据变化
  1007. const oldTag = this.oldCheckboxTagList[this.currentTagIndex] || {};
  1008. const currentTag = this.checkboxTagList[this.currentTagIndex] || {};
  1009. recordOldVlaue = `${oldTag.tagValue || ''}:${oldTag.checked ? '勾选' : '未勾选'}`;
  1010. recordValue = `${currentTag.tagValue || ''}:${currentTag.checked ? '勾选' : '未勾选'}`;
  1011. isModify = oldTag.checked !== undefined;
  1012. } else if (this.type === "fqyq") {
  1013. const current = this.getFqyqInfo();
  1014. recordOldVlaue = `${current.des+current.oldValue}`;
  1015. recordValue = `${current.des+current.newValue}`;
  1016. isModify = !!this.oldFqyqValue.mainRadio
  1017. }else if(this.type === "checkboxList"){
  1018. const current = this.getCheckboxListInfo();
  1019. recordOldVlaue = `${current.des+(current.oldValue || '')}`;
  1020. recordValue = `${current.des+(current.newValue || '')}`;
  1021. isModify = !!current.oldValue;
  1022. }
  1023. const record = {
  1024. ...baseInfo,
  1025. oldValue: recordOldVlaue,
  1026. value: recordValue,
  1027. title: isModify ? "修改" : "提交",
  1028. time: moment().format("YYYY-MM-DD HH:mm:ss"),
  1029. }
  1030. if (data) {
  1031. record.reason = data.remark
  1032. }
  1033. const params = {
  1034. type: "fieldChanged",
  1035. newRecord: [record],
  1036. resourceList: this.getZdxgjl(),
  1037. }
  1038. // 更新oldValue和oldOtherValues
  1039. if (this.type === 'checkboxList') {
  1040. this.oldCheckboxListValue = JSON.parse(JSON.stringify(this.checkboxListValue));
  1041. } else if (this.type === "checkboxTag") {
  1042. // checkboxTag类型,只更新当前tagIndex的数据
  1043. if (this.currentTagIndex >= 0 && this.currentTagIndex < this.checkboxTagList.length) {
  1044. this.oldCheckboxTagList[this.currentTagIndex] = { ...this.checkboxTagList[this.currentTagIndex] };
  1045. } else {
  1046. // 如果没有指定tagIndex,更新整个数组
  1047. this.oldCheckboxTagList = JSON.parse(JSON.stringify(this.checkboxTagList));
  1048. }
  1049. } else if (this.type === "fqyq") {
  1050. // 如果没有指定字段,更新整个对象
  1051. this.oldFqyqValue = JSON.parse(JSON.stringify(this.fqyqValue));
  1052. }
  1053. let value = this.inputValue;
  1054. if (this.type === 'checkboxList') {
  1055. value = {
  1056. checkboxValues: this.checkboxListValue.checkboxValues,
  1057. otherValues: this.checkboxListValue.otherValues
  1058. };
  1059. } else if (this.type === "checkboxTag") {
  1060. value = [...this.checkboxTagList];
  1061. } else if (this.type === "fqyq") {
  1062. value = { ...this.fqyqValue };
  1063. }
  1064. if (this.type === "button") {
  1065. this.$emit('clickButton', this.item, this.inputValue, data);
  1066. if (this.templateFillType === "preFill") {
  1067. return;
  1068. }
  1069. }
  1070. //用户输入密码并点击确定,保存修改
  1071. this.oldValue = value; // 更新旧值
  1072. this.$emit("blur", value);
  1073. this.$emit('input', value);
  1074. this.$emit("change", value, data ? "save" : "");
  1075. if (this.item.type === "clickable") {//clickable的丢给父级去处理
  1076. return;
  1077. }
  1078. if (this.templateFillType === "actFill") {//只有实际填报的时候才记录修改记录
  1079. this.updateZdxgjl(record);
  1080. }
  1081. this.$nextTick(() => {
  1082. EventBus.$emit('onModifyRecord', params,)
  1083. console.log(params, "onModifyRecord")
  1084. if (this.regentType.includes(this.item.type)) {
  1085. this.$emit("onRegentSubmit", this.selectRegentInfo, this.inputValue);
  1086. }
  1087. })
  1088. },
  1089. //判断两个值是否相等
  1090. isEqual(oldValue, nowValue) {
  1091. if (oldValue === null || nowValue === null) {
  1092. return oldValue === nowValue;
  1093. }
  1094. if (typeof oldValue === 'object' && typeof nowValue === 'object') {
  1095. return JSON.stringify(oldValue) === JSON.stringify(nowValue);
  1096. }
  1097. return oldValue === nowValue;
  1098. },
  1099. //获取公共记录信息
  1100. getCommonRecordInfo() {
  1101. const { nickName, name } = this.$store.getters;
  1102. //locale:zh-CN 中文 en-US 英文
  1103. const { label, parentLabel } = this.item;
  1104. let fieldLabelCn = this.$i18n.t(label, "zh_CN"), fieldLabelEn = this.$i18n.t(label, "en_US");
  1105. if (label === "template.common.other") {
  1106. fieldLabelCn = this.$i18n.t(parentLabel, "zh_CN") + this.$i18n.t("template.common.otherInfo", "zh_CN");
  1107. fieldLabelEn = this.$i18n.t(parentLabel, "en_US") + this.$i18n.t("template.common.otherInfo", "en_US");
  1108. } else if (!label && parentLabel == "template.common.remark") {
  1109. fieldLabelCn = this.$i18n.t(parentLabel, "zh_CN") + this.$i18n.t("template.common.unit", "zh_CN");
  1110. fieldLabelEn = this.$i18n.t(parentLabel, "en_US") + this.$i18n.t("template.common.unit", "en_US");
  1111. }
  1112. const commonInfo = {
  1113. userNameCn: nickName,
  1114. userNameEn: name,
  1115. key: this.fieldKey,
  1116. fieldCn: `${this.$i18n.t(this.fieldItemLabel, "zh_CN")}` + (fieldLabelCn ? ("-" + fieldLabelCn) : ""),
  1117. fieldEn: `${this.$i18n.t(this.fieldItemLabel, "en_US")}` + (fieldLabelEn ? ("-" + fieldLabelEn) : ""),
  1118. }
  1119. return commonInfo;
  1120. },
  1121. // 判断值是否为空
  1122. isValueEmpty(value) {
  1123. if (value === null || value === undefined || value === '') {
  1124. return true;
  1125. }
  1126. if (typeof value === 'string' && value.trim() === '') {
  1127. return true;
  1128. }
  1129. if (Array.isArray(value) && value.length === 0) {
  1130. return true;
  1131. }
  1132. if (Object.keys(value).length === 0) {
  1133. return true;
  1134. }
  1135. return false;
  1136. },
  1137. // 判断checkboxList中特定otherCode输入框是否有错误
  1138. isOtherInputError(otherCode) {
  1139. if (!this.error) {
  1140. return false;
  1141. }
  1142. // 检查该otherCode对应的输入框是否为空
  1143. return isValueEmpty(this.otherValues[otherCode]);
  1144. },
  1145. handleClickable(item, event) {
  1146. if (this.templateFillType !== 'actFill') {
  1147. return
  1148. }
  1149. this.$emit("clickable", item)
  1150. },
  1151. //判断是否禁用复选框
  1152. getCheckboxDisabled() {
  1153. //只有qc能操作checkbox,其他都只能看。
  1154. return this.templateFillType !== 'qc'
  1155. },
  1156. //判断是否显示复选框图标
  1157. getIsShowCheckboxIcon() {
  1158. if (this.templateFillType === 'qc') {
  1159. return true;
  1160. }
  1161. return this.getChecked();
  1162. },
  1163. //判断是否显示复制按钮
  1164. getIsShowCopyIcon() {
  1165. const { copyFrom } = this.item;
  1166. return copyFrom && this.templateFillType === "actFill";
  1167. },
  1168. //判断是否显示操作按钮
  1169. isShowHandle() {
  1170. const { fillType } = this.item;
  1171. //只有当模板状态不是预填时,才显示操作按钮
  1172. return this.templateFillType !== "preFill" && fillType === "actFill" && this.type !== "button"
  1173. },
  1174. //判断是否禁用
  1175. getDisabled() {
  1176. const { item } = this;
  1177. const { fillType } = item;
  1178. if (item.hasOwnProperty("disabled")) {
  1179. return item.disabled
  1180. } else {
  1181. if (fillType === "actFill") {//当模板状态是实际填写时,只有当fillType是actFill时才能填写
  1182. return this.templateFillType !== "actFill"
  1183. } else if (fillType === "preFill") {//当模板状态是预填写时,只有当fillType是preFill才能填写
  1184. return this.templateFillType !== "preFill"
  1185. } else {
  1186. return true
  1187. }
  1188. }
  1189. },
  1190. getPlaceholder() {
  1191. const { placeholder, label } = this.item;
  1192. const { type } = this;
  1193. if (this.getDisabled()) {
  1194. return ""
  1195. }
  1196. if (this.regentType.includes(type) || type === "clickable" || type === "fqyq") {
  1197. return this.$t("template.common.pleaseSelect")
  1198. }
  1199. let prex = "template.common.pleaseFillIn"
  1200. if (type === "select" || type === "dateTime") {
  1201. prex = "template.common.pleaseSelect"
  1202. }
  1203. return placeholder ? this.$t(placeholder) : (this.$t(prex) + this.$t(label))
  1204. },
  1205. async onCopy() {
  1206. // 触发复制事件
  1207. this.$emit("copy");
  1208. // 等待复制操作完成后,调用保存记录方法
  1209. this.$nextTick(async () => {
  1210. await this.onCommonHandleSaveRecord(this.inputValue);
  1211. });
  1212. },
  1213. //判断是否显示问题图标
  1214. getIsShowQuestionIcon() {
  1215. if (this.templateFillType === "qc") {//qc可以直接查看
  1216. return true;
  1217. }
  1218. return this.getReplyRecords().length > 0;
  1219. },
  1220. //判断是否显示修改记录图标
  1221. getIsShowRecordIcon() {
  1222. return this.getModifyRecords().length > 0
  1223. },
  1224. //获取回复记录
  1225. getReplyRecords() {
  1226. const { fieldKey, getFhyjjl } = this;
  1227. const records = getFhyjjl()?.filter(item => item.key === fieldKey) || [];
  1228. return records;
  1229. },
  1230. //获取字段修改记录
  1231. getModifyRecords() {
  1232. const { fieldKey, getZdxgjl } = this;
  1233. const records = getZdxgjl().filter(item => item.key === fieldKey);
  1234. return records;
  1235. },
  1236. // 鼠标进入主容器
  1237. async onMouseEnter(type, event) {
  1238. this.currentRecordType = type;
  1239. clearTimeout(this.modalTimer);
  1240. let record = [];
  1241. if (type === "fieldChanged") {
  1242. record = this.getModifyRecords();
  1243. } else if (type === "replyRecord") {
  1244. record = this.getReplyRecords();
  1245. }
  1246. this.modificationRecords = record;
  1247. // 先计算模态框位置,避免闪烁
  1248. this.showModal = true;
  1249. this.$nextTick(() => {
  1250. if (this.$refs.modalRef) {
  1251. const elementRect = event.target.getBoundingClientRect();
  1252. const modalEl = this.$refs.modalRef;
  1253. // 获取模态框的宽度和高度
  1254. const modalWidth = modalEl.offsetWidth || 250; // 默认宽度
  1255. const modalHeight = modalEl.offsetHeight || 300; // 默认高度
  1256. const viewportWidth = window.innerWidth;
  1257. const viewportHeight = window.innerHeight;
  1258. // 计算模态框位置
  1259. let leftPos, topPos;
  1260. // 检查右侧空间是否足够
  1261. if (elementRect.right + modalWidth + 5 <= viewportWidth) {
  1262. // 右侧空间充足,显示在右侧
  1263. leftPos = elementRect.right + 5 + 'px';
  1264. } else if (elementRect.left - modalWidth - 5 >= 0) {
  1265. // 左侧空间充足,显示在左侧
  1266. leftPos = elementRect.left - modalWidth - 5 + 'px';
  1267. } else {
  1268. // 两侧空间都不足,选择空间更大的一边
  1269. if (elementRect.left > viewportWidth - elementRect.right) {
  1270. // 左侧空间更大,显示在左侧
  1271. leftPos = Math.max(5, elementRect.left - modalWidth - 5) + 'px';
  1272. } else {
  1273. // 右侧空间更大,显示在右侧(可能会超出屏幕,但尽量靠近边缘)
  1274. leftPos = Math.min(elementRect.right + 5, viewportWidth - 5) + 'px';
  1275. }
  1276. }
  1277. // 计算顶部位置,确保不超出屏幕上下边界
  1278. topPos = Math.max(5, Math.min(elementRect.top, viewportHeight - modalHeight - 5)) + 'px';
  1279. // 设置模态框位置
  1280. modalEl.style.left = leftPos;
  1281. modalEl.style.top = topPos;
  1282. }
  1283. });
  1284. },
  1285. // 鼠标离开主容器
  1286. onMouseLeave() {
  1287. // this.currentRecordType = '';
  1288. // this.modificationRecords = [];//清空数据源
  1289. // 延迟隐藏模态框,让用户有机会移动到模态框上
  1290. this.modalTimer = setTimeout(() => {
  1291. if (!this.isHoveringModal) {
  1292. this.showModal = false;
  1293. }
  1294. }, 100);
  1295. },
  1296. // 鼠标进入模态框
  1297. onModalEnter() {
  1298. this.isHoveringModal = true;
  1299. clearTimeout(this.modalTimer);
  1300. },
  1301. // 鼠标离开模态框
  1302. onModalLeave() {
  1303. this.isHoveringModal = false;
  1304. this.currentRecordType = "";
  1305. this.modificationRecords = [];//清空数据源
  1306. this.modalTimer = setTimeout(() => {
  1307. this.showModal = false;
  1308. }, 100);
  1309. },
  1310. },
  1311. }
  1312. </script>
  1313. <style lang="scss">
  1314. .flex {
  1315. display: flex;
  1316. align-items: center;
  1317. }
  1318. .flex1 {
  1319. flex: 1;
  1320. }
  1321. .handle-row {
  1322. margin-left: 5px;
  1323. display: flex;
  1324. align-items: center;
  1325. cursor: pointer;
  1326. }
  1327. .w-100 {
  1328. width: 100%;
  1329. }
  1330. .handle-icon {
  1331. width: 18px;
  1332. height: 18px;
  1333. &:not(:last-child) {
  1334. margin-right: 5px;
  1335. }
  1336. }
  1337. .mr-5 {
  1338. margin-right: 5px !important;
  1339. }
  1340. .orange {
  1341. color: #f9c588;
  1342. }
  1343. .green {
  1344. color: green;
  1345. }
  1346. .gray {
  1347. color: #b2b2b2;
  1348. }
  1349. .orange-border {
  1350. .el-input-group__prepend,
  1351. input,
  1352. textarea {
  1353. border-color: #f9c588;
  1354. &:focus {
  1355. border-color: #f9c588;
  1356. }
  1357. &:hover {
  1358. border-color: #f9c588;
  1359. }
  1360. &:disabled {
  1361. border-color: #f9c588 !important;
  1362. }
  1363. }
  1364. .el-checkbox__inner {
  1365. border-color: #f9c588 !important;
  1366. }
  1367. }
  1368. .el-button--primary {
  1369. &.orange-border {
  1370. background-color: #f79b31 !important;
  1371. border-color: #f79b31 !important;
  1372. &:hover {
  1373. background-color: #f79b31 !important;
  1374. }
  1375. &:disabled {
  1376. background-color: rgba(#f79b31, .8) !important;
  1377. border-color: rgba(#f79b31, .8) !important;
  1378. }
  1379. &:active {
  1380. background-color: rgba(#f79b31, .8) !important;
  1381. border-color: rgba(#f79b31, .8) !important;
  1382. }
  1383. }
  1384. &.blue-border {
  1385. background-color: #4ea2ff !important;
  1386. border-color: #4ea2ff !important;
  1387. &:hover {
  1388. background-color: #4ea2ff !important;
  1389. }
  1390. &:disabled {
  1391. background-color: rgba(#4ea2ff, .8) !important;
  1392. border-color: rgba(#4ea2ff, .8) !important;
  1393. }
  1394. &:active {
  1395. background-color: rgba(#4ea2ff, .8) !important;
  1396. border-color: rgba(#4ea2ff, .8) !important;
  1397. }
  1398. }
  1399. }
  1400. .green-border {
  1401. .el-input-group__prepend,
  1402. input,
  1403. textarea {
  1404. border-color: green;
  1405. &:focus {
  1406. border-color: green;
  1407. }
  1408. &:hover {
  1409. border-color: green;
  1410. }
  1411. &:disabled {
  1412. border-color: green !important;
  1413. }
  1414. }
  1415. }
  1416. .blue-border {
  1417. .el-input-group__prepend,
  1418. input,
  1419. .el-checkbox__inner,
  1420. textarea {
  1421. border-color: #4ea2ff;
  1422. &:focus {
  1423. border-color: #4ea2ff;
  1424. }
  1425. &:hover {
  1426. border-color: #4ea2ff;
  1427. }
  1428. &:disabled {
  1429. border-color: #4ea2ff !important;
  1430. }
  1431. }
  1432. }
  1433. .error-border {
  1434. .el-input-group__prepend,
  1435. input,
  1436. textarea,
  1437. .el-select,
  1438. .clickable,
  1439. .el-date-editor {
  1440. border-color: #ff5d5d;
  1441. box-shadow: 0 0 6px #ffc3c3 !important;
  1442. &:focus {
  1443. border-color: #ff5d5d;
  1444. box-shadow: 0 0 6px #ffc3c3 !important;
  1445. }
  1446. &:hover {
  1447. border-color: #ff5d5d;
  1448. box-shadow: 0 0 6px #ffc3c3 !important;
  1449. }
  1450. }
  1451. // 为 el-select 和 el-date-picker 添加错误边框样式
  1452. .el-select .el-input__inner,
  1453. .el-date-editor .el-input__inner .el-checkbox__inner {
  1454. border-color: #ff5d5d;
  1455. box-shadow: 0 0 6px #ffc3c3 !important;
  1456. }
  1457. // 处理 DecimalInput 组件的错误边框样式
  1458. :deep(.el-input-number) {
  1459. .el-input__inner {
  1460. border-color: #ff5d5d;
  1461. box-shadow: 0 0 6px #ffc3c3 !important;
  1462. }
  1463. }
  1464. // 为点击式表单项添加错误边框样式
  1465. .clickable {
  1466. border-color: #ff5d5d;
  1467. box-shadow: 0 0 6px #ffc3c3 !important;
  1468. }
  1469. }
  1470. .orange-bg {
  1471. background-color: #FFF1F1 !important; // 橙色背景,透明度适中
  1472. input,
  1473. textarea,
  1474. .el-input__inner,
  1475. .el-textarea__inner {
  1476. background-color: #FFF1F1 !important;
  1477. }
  1478. }
  1479. .modification-modal {
  1480. position: fixed;
  1481. z-index: 9999;
  1482. background-color: rgba(0, 0, 0, 0.7);
  1483. border-radius: 4px;
  1484. padding: 10px;
  1485. color: white;
  1486. max-height: 300px;
  1487. min-width: 250px;
  1488. overflow: hidden;
  1489. pointer-events: auto;
  1490. opacity: 0;
  1491. transform: scale(0.9);
  1492. transition: opacity 0.2s ease, transform 0.2s ease;
  1493. }
  1494. .modification-modal.show {
  1495. opacity: 1;
  1496. transform: scale(1);
  1497. }
  1498. .modification-modal .modal-content {
  1499. max-height: 280px;
  1500. overflow-y: auto;
  1501. padding-right: 5px;
  1502. }
  1503. .modification-modal .modal-content h4 {
  1504. margin: 0 0 10px 0;
  1505. font-size: 14px;
  1506. border-bottom: 1px solid #ccc;
  1507. padding-bottom: 5px;
  1508. }
  1509. .modification-modal .records-list {
  1510. font-size: 12px;
  1511. }
  1512. .modification-modal .record-item p {
  1513. margin: 5px 0;
  1514. word-break: break-all;
  1515. }
  1516. .modification-modal .record-item hr {
  1517. border: 0;
  1518. border-top: 1px solid #555;
  1519. margin: 8px 0;
  1520. }
  1521. .modification-modal .no-records {
  1522. text-align: center;
  1523. color: #aaa;
  1524. font-style: italic;
  1525. }
  1526. .clickable {
  1527. cursor: pointer;
  1528. width: auto;
  1529. // margin-left: 10px;
  1530. min-height: 28px;
  1531. line-height: 28px;
  1532. word-break: break-all;
  1533. border-radius: 4px;
  1534. border: 1px solid #4ea2ff;
  1535. display: flex;
  1536. align-items: center;
  1537. padding: 0 15px;
  1538. font-size: 14px;
  1539. font-weight: normal;
  1540. color: #606266;
  1541. flex: 1;
  1542. &.disabled {
  1543. cursor: not-allowed;
  1544. color: #c0c4cc;
  1545. background-color: #f5f7fa;
  1546. }
  1547. &.error-border {
  1548. border-color: #ff5d5d !important;
  1549. box-shadow: 0 0 6px #ffc3c3 !important;
  1550. }
  1551. }
  1552. .dialog-footer {
  1553. display: flex;
  1554. justify-content: flex-end;
  1555. }
  1556. .atta-tips {
  1557. color: #ff5d5d;
  1558. font-size: 12px;
  1559. margin-left: 5px;
  1560. }
  1561. .checkbox-list-container {
  1562. padding: 12px;
  1563. border: 1px solid #dcdfe6;
  1564. border-radius: 4px;
  1565. transition: all 0.3s;
  1566. &.error-border {
  1567. border-color: #ff5d5d !important;
  1568. box-shadow: 0 0 6px #ffc3c3 !important;
  1569. }
  1570. .checkbox-item {
  1571. margin-right: 16px;
  1572. display: flex;
  1573. align-items: center;
  1574. &:not(:last-child) {
  1575. margin-bottom: 10px;
  1576. }
  1577. // display: inline-block;
  1578. .el-input {
  1579. width: 200px;
  1580. margin-left: 10px;
  1581. &.error-border {
  1582. .el-input__inner {
  1583. border-color: #ff5d5d !important;
  1584. box-shadow: 0 0 6px #ffc3c3 !important;
  1585. }
  1586. }
  1587. }
  1588. }
  1589. }
  1590. .orange-border {
  1591. .checkbox-list-container {
  1592. border-color: #f9c588;
  1593. &:hover {
  1594. border-color: #f79b31;
  1595. }
  1596. }
  1597. .el-checkbox {
  1598. &.is-checked {
  1599. .el-checkbox__label {
  1600. color: #606266;
  1601. }
  1602. .el-checkbox__inner {
  1603. background-color: #f9c588;
  1604. border-color: #f9c588;
  1605. }
  1606. }
  1607. }
  1608. .el-radio {
  1609. &.is-checked {
  1610. .el-radio__label {
  1611. color: #606266;
  1612. }
  1613. .el-radio__inner {
  1614. background-color: #f9c588;
  1615. border-color: #f9c588;
  1616. }
  1617. }
  1618. .el-radio__inner {
  1619. border-color: #f9c588;
  1620. }
  1621. }
  1622. }
  1623. .orange-bg {
  1624. .checkbox-list-container {
  1625. background-color: #FFF1F1 !important;
  1626. border-color: #f9c588;
  1627. }
  1628. }
  1629. // checkboxTag样式
  1630. .checkbox-tag-wrapper {
  1631. display: flex;
  1632. flex-wrap: wrap;
  1633. gap: 10px;
  1634. padding: 8px;
  1635. }
  1636. .checkbox-tag-container {
  1637. border-radius: 4px;
  1638. .checkbox-tag-item {
  1639. display: flex;
  1640. align-items: center;
  1641. gap: 8px;
  1642. .tag-content {
  1643. cursor: pointer;
  1644. position: relative;
  1645. .tag-input {
  1646. width: 100px;
  1647. }
  1648. .tag-display {
  1649. cursor: pointer;
  1650. user-select: none;
  1651. }
  1652. }
  1653. .delete-icon {
  1654. cursor: pointer;
  1655. color: #909399;
  1656. font-size: 12px;
  1657. padding: 2px;
  1658. border-radius: 50%;
  1659. position: absolute;
  1660. top: 6px;
  1661. right: 5px;
  1662. color: red;
  1663. background-color: #f5f5f5;
  1664. }
  1665. }
  1666. }
  1667. .fqyq-input{
  1668. width: 500px;
  1669. margin-right:10px;
  1670. }
  1671. .mb-10{
  1672. margin-bottom: 10px;
  1673. }
  1674. .fs-14{
  1675. font-size: 14px;
  1676. }
  1677. .mr-10{
  1678. margin-right: 10px;
  1679. }
  1680. </style>