华西海圻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.

76 lines
2.7 KiB

  1. import { EventBus } from "@/utils/eventBus";
  2. import { getuuid } from "@/utils/index";
  3. import moment from "moment";
  4. export default {
  5. inject: ["templateFillType"],
  6. data() {
  7. return {
  8. uuid: getuuid(),
  9. deleteIndex: 0,
  10. }
  11. },
  12. mounted() {
  13. EventBus.$on('onEditSignCallback', this.handleEditSignCallback);
  14. },
  15. unmounted() {
  16. EventBus.$off('onEditSignCallback', this.handleEditSignCallback);
  17. },
  18. methods: {
  19. handleEditSignCallback(data) {
  20. if (data.uuid === this.uuid) {
  21. console.log(this.columns, this.templateFillType, data, "this.columns")
  22. const { qmrMc, qmrMcEn, remark } = data.data;
  23. const { fieldItemLabel, columnsData } = this.columns;
  24. const { row } = this;
  25. const desArr = columnsData.map((item) => {
  26. const label = this.$t(item.label), otherValue = "", subValue = "", mainValue = row[item.prop];
  27. if (item.bodySubKey && (item.bodySubType !== "button")) {
  28. subValue = row[item.bodySubKey];
  29. }
  30. if (item.otherCode) {
  31. otherValue = row[item.otherCode];
  32. }
  33. const desStr = `${label}:${mainValue}${subValue ? `[${subValue}]` : ''}${otherValue ? `[${otherValue}]` : ''}`;
  34. return desStr;
  35. });
  36. const record = [
  37. {
  38. "userNameCn": qmrMc,
  39. "userNameEn": qmrMcEn,
  40. "fieldCn": this.$t(fieldItemLabel, 'zh_CN'),
  41. "fieldEn": this.$t(fieldItemLabel, 'en_US'),
  42. "oldValue": desArr.join(";"),
  43. "value": "",
  44. "title": "修改",
  45. "time": moment().format("YYYY-MM-DD HH:mm:ss"),
  46. "reason": remark
  47. }
  48. ]
  49. this.sureDelete(record);
  50. }
  51. },
  52. sureDelete(record) {
  53. this.$emit("deleteRow", this.deleteIndex);
  54. setTimeout(() => {
  55. const params = {
  56. type: "fieldChanged",
  57. newRecord: record || null,
  58. resourceList: null,
  59. }
  60. EventBus.$emit('onModifyRecord', params,)
  61. }, 30);
  62. },
  63. // 删除行
  64. deleteRow(index) {
  65. this.deleteIndex = index;
  66. if (this.templateFillType === "actFill") {
  67. EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
  68. } else {
  69. this.sureDelete();
  70. }
  71. }
  72. },
  73. }