CesOrderCommentForm.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model
  5. ref="form"
  6. :model="model"
  7. :rules="validatorRules"
  8. slot="detail"
  9. >
  10. <a-row>
  11. <a-col :span="24">
  12. <a-form-model-item
  13. label="评分"
  14. :labelCol="labelCol"
  15. :wrapperCol="wrapperCol"
  16. prop="score"
  17. >
  18. <a-input-number
  19. v-model="model.score"
  20. placeholder="请输入评价1-5星"
  21. style="width: 100%"
  22. disabled
  23. />
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :span="24">
  27. <a-form-model-item
  28. label="评价图片"
  29. :labelCol="labelCol"
  30. :wrapperCol="wrapperCol"
  31. prop="images"
  32. >
  33. <img
  34. width="100"
  35. style="padding:5px;"
  36. :src="image"
  37. v-for="(image, index) in images"
  38. :key="index"
  39. />
  40. </a-form-model-item>
  41. </a-col>
  42. <a-col :span="24">
  43. <a-form-model-item
  44. label="评价内容"
  45. :labelCol="labelCol"
  46. :wrapperCol="wrapperCol"
  47. prop="contentBody"
  48. >
  49. <a-textarea
  50. v-model="model.contentBody"
  51. rows="4"
  52. placeholder="请输入评价内容"
  53. disabled
  54. />
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :span="24">
  58. <a-form-model-item
  59. label="商家回复"
  60. :labelCol="labelCol"
  61. :wrapperCol="wrapperCol"
  62. prop="sellerContent"
  63. >
  64. <a-textarea
  65. v-model="model.sellerContent"
  66. rows="4"
  67. placeholder="请输入商家回复"
  68. />
  69. </a-form-model-item>
  70. </a-col>
  71. </a-row>
  72. </a-form-model>
  73. </j-form-container>
  74. </a-spin>
  75. </template>
  76. <script>
  77. import { httpAction, getAction } from "@/api/manage";
  78. import { validateDuplicateValue } from "@/utils/util";
  79. export default {
  80. name: "CesOrderCommentForm",
  81. components: {},
  82. props: {
  83. //表单禁用
  84. disabled: {
  85. type: Boolean,
  86. default: false,
  87. required: false,
  88. },
  89. },
  90. data() {
  91. return {
  92. model: {},
  93. labelCol: {
  94. xs: { span: 24 },
  95. sm: { span: 5 },
  96. },
  97. wrapperCol: {
  98. xs: { span: 24 },
  99. sm: { span: 16 },
  100. },
  101. confirmLoading: false,
  102. validatorRules: {
  103. sellerContent: [{ required: true, message: "请输入商家回复!" }],
  104. },
  105. url: {
  106. add: "/order/cesOrderComment/add",
  107. edit: "/order/cesOrderComment/edit",
  108. queryById: "/order/cesOrderComment/queryById",
  109. },
  110. images: [],
  111. };
  112. },
  113. computed: {
  114. formDisabled() {
  115. return this.disabled;
  116. },
  117. },
  118. created() {
  119. //备份model原始值
  120. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  121. },
  122. methods: {
  123. add() {
  124. this.edit(this.modelDefault);
  125. },
  126. edit(record) {
  127. this.model = Object.assign({}, record);
  128. this.visible = true;
  129. if (this.model.images) {
  130. this.images = this.model.images.split(",");
  131. }
  132. },
  133. submitForm() {
  134. const that = this;
  135. // 触发表单验证
  136. this.$refs.form.validate((valid) => {
  137. if (valid) {
  138. that.confirmLoading = true;
  139. let httpurl = "";
  140. let method = "";
  141. if (!this.model.id) {
  142. httpurl += this.url.add;
  143. method = "post";
  144. } else {
  145. httpurl += this.url.edit;
  146. method = "put";
  147. }
  148. httpAction(httpurl, this.model, method)
  149. .then((res) => {
  150. if (res.success) {
  151. that.$message.success(res.message);
  152. that.$emit("ok");
  153. } else {
  154. that.$message.warning(res.message);
  155. }
  156. })
  157. .finally(() => {
  158. that.confirmLoading = false;
  159. });
  160. }
  161. });
  162. },
  163. },
  164. };
  165. </script>