handle-online-form.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <el-form
  3. v-loading="loading"
  4. ref="ruleForm"
  5. :model="ruleForm"
  6. status-icon
  7. :rules="rulesThis"
  8. :label-width="labelWidth || '110px'"
  9. class="demo-ruleForm-goodsOnline"
  10. :size="'mini'"
  11. >
  12. <el-row>
  13. <el-col :span="12"
  14. ><el-form-item label="平台商品编码" prop="plat_code">
  15. <el-input
  16. v-model="ruleForm.plat_code"
  17. placeholder="平台商品编码"
  18. maxlength="50"
  19. ></el-input>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="12" class="tr">
  23. <el-button :size="'mini'" type="primary" @click="submitForm"
  24. >保 存
  25. </el-button>
  26. </el-col>
  27. </el-row>
  28. </el-form>
  29. </template>
  30. <script>
  31. import costFormAddEdit from "./costFormAddEdit";
  32. import asyncRequest from "@/apis/service/goodStore/goodsOnline";
  33. export default {
  34. name: "exam-form",
  35. props: [
  36. "size",
  37. "statusList",
  38. "disabled",
  39. "isMust",
  40. "labelWidth",
  41. "id",
  42. "code",
  43. ],
  44. components: {
  45. costFormAddEdit,
  46. },
  47. /**
  48. * 属性集合
  49. * @param {String} size : 组件大小 非必填
  50. * @param {Array} statusList : 驳回至备选项 必填
  51. * @param {Boolean} disabled : 是否禁用 必填
  52. * @param {Boolean} isMust : 是否需要展示驳回节点 必填
  53. *
  54. *
  55. */
  56. /**
  57. * 事件集合
  58. * @searchChange : 选中值变化调用 抛出选中数据
  59. */
  60. data() {
  61. return {
  62. loading: false,
  63. showModelThis: this.showModel,
  64. pickerOptions: {
  65. disabledDate(time) {
  66. return time.getTime() < Date.now() - 60 * 60 * 24 * 1000;
  67. },
  68. },
  69. ruleForm: {
  70. plat_code: "",
  71. },
  72. rulesThis: this.rules,
  73. rules: {
  74. plat_code: [
  75. {
  76. required: true,
  77. message: "平台商品编码不能为空",
  78. trigger: "blur",
  79. },
  80. ],
  81. },
  82. };
  83. },
  84. newTime: function (val) {
  85. if (val) {
  86. this.initForm();
  87. }
  88. },
  89. mounted() {
  90. this.initForm();
  91. },
  92. methods: {
  93. async initForm() {
  94. this.loading = true;
  95. this.rulesThis = this.rules;
  96. await this.resetForm();
  97. this.loading = false;
  98. },
  99. async resetForm() {
  100. // 重置
  101. await this.$nextTick(() => {
  102. if (this.$refs.ruleForm) {
  103. this.$refs.ruleForm.resetFields();
  104. this.$refs.ruleForm.clearValidate();
  105. this.ruleForm = {
  106. plat_code: this.code || "",
  107. };
  108. }
  109. });
  110. },
  111. async submitForm() {
  112. await this.$refs.ruleForm.validate(async (valid) => {
  113. if (valid) {
  114. let model = JSON.parse(JSON.stringify(this.ruleForm));
  115. // 刷新
  116. this.$emit("resSuccess", model);
  117. // this.routeReGoto("goodsOnline", {});
  118. } else {
  119. console.log("error submit!!");
  120. return false;
  121. }
  122. });
  123. },
  124. },
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. .demo-ruleForm-goodsOnline {
  129. .shangchuan-ul {
  130. li {
  131. position: relative;
  132. width: 100%;
  133. &.tupian {
  134. }
  135. }
  136. }
  137. }
  138. </style>