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

66 lines
1.7 KiB

  1. export default {
  2. props: {
  3. templateData: {
  4. type: Object,
  5. default: () => {},
  6. },
  7. },
  8. watch: {
  9. templateData: {
  10. immediate: true,
  11. handler(v) {
  12. if(v){
  13. let n = {...v};
  14. if(v.bdnr){
  15. n = {...n,...JSON.parse(v.bdnr)};
  16. }
  17. this.formData = n;
  18. this.setTemplateData(n);
  19. }
  20. }
  21. }
  22. },
  23. data() {
  24. },
  25. mounted() {
  26. setTimeout(() => {
  27. this.setConditionOptions(
  28. [
  29. { label: "条件5", value: "1" },
  30. { label: "条件6", value: "2" },
  31. { label: "条件7", value: "3" },
  32. { label: "其他", value: "-1" },
  33. ]
  34. )
  35. }, 1000);
  36. this.setTemplateStatus("preFill");
  37. // this.setTemplateStatus(this.fillType)
  38. },
  39. unmounted() {
  40. this.setTemplateStatus("");
  41. this.setTemplateData({});
  42. },
  43. methods: {
  44. setTemplateStatus(status) {
  45. this.$store.commit('template/SET_TEMPLATE_STATUS', status)
  46. },
  47. setConditionOptions(options) {
  48. this.$store.commit('template/SET_CONDITION_OPTIONS', options)
  49. },
  50. //统一处理blur事件,因为有效周期和过期日期是相关的,所以需要在有效周期失焦时更新过期日期
  51. onHandleBlur(fields){
  52. const {key ,effectivePeriodUnit,effectivePeriod} = fields;
  53. const {createTime} = this.formData;
  54. if(key ==="effectivePeriod"){//统一处理有效周期失焦,计算失效事件,保证字段名不能变
  55. const start = moment(createTime);
  56. const end = start.add(Number(effectivePeriod), effectivePeriodUnit).format("YYYY-MM-DD HH:mm:ss");
  57. this.$refs.stepFormPackageRef.updateFormField("expireDate", end);
  58. }
  59. }
  60. },
  61. }