set-active-price-form.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :title="'编辑活动信息'"
  5. :center="true"
  6. align="left"
  7. top="12vh"
  8. width="600px"
  9. :size="'mini'"
  10. :close-on-click-modal="false"
  11. :visible.sync="showModelThis"
  12. element-loading-text="拼命加载中"
  13. element-loading-spinner="el-icon-loading"
  14. element-loading-background="rgba(0, 0, 0, 0.8)"
  15. @close="showModelThis = false"
  16. >
  17. <el-card style="margin: -20px 0 0 0">
  18. <el-row :gutter="10">
  19. <el-col :span="24">
  20. <el-form
  21. ref="ruleForm"
  22. :model="ruleForm"
  23. status-icon
  24. :rules="rulesThis"
  25. label-width="80px"
  26. class="demo-ruleForm"
  27. >
  28. <el-form-item label="商品编号" prop="skuCode">
  29. <el-input
  30. v-model="ruleForm.skuCode"
  31. placeholder="商品编号"
  32. minlength="100"
  33. disabled
  34. />
  35. </el-form-item>
  36. <el-form-item label="商品名称" prop="good_name">
  37. <el-input
  38. v-model="ruleForm.good_name"
  39. disabled
  40. placeholder="商品名称"
  41. minlength="100"
  42. />
  43. </el-form-item>
  44. <el-form-item label="活动库存" prop="activity_stock">
  45. <el-input
  46. v-model="ruleForm.activity_stock"
  47. disabled
  48. placeholder="活动库存"
  49. minlength="100"
  50. />
  51. </el-form-item>
  52. <el-form-item label="起订量" prop="moq_num">
  53. <el-input
  54. v-model="ruleForm.moq_num"
  55. disabled
  56. placeholder="起订量"
  57. minlength="100"
  58. />
  59. </el-form-item>
  60. <el-form-item label="成本单价" prop="cost_price">
  61. <el-input
  62. v-model="ruleForm.cost_price"
  63. disabled
  64. placeholder="成本单价"
  65. minlength="100"
  66. >
  67. <template slot="append">元</template></el-input
  68. >
  69. </el-form-item>
  70. <el-form-item label="非活动价" prop="sale_price">
  71. <el-input
  72. v-model="ruleForm.sale_price"
  73. disabled
  74. placeholder="非活动价"
  75. minlength="100"
  76. >
  77. <template slot="append">元</template></el-input
  78. >
  79. </el-form-item>
  80. <el-form-item label="活动价" prop="activity_price">
  81. <digital-input
  82. :values="ruleForm.activity_price"
  83. :placeholder="'活动价'"
  84. :min="0"
  85. :max="10000000000"
  86. :position="'right'"
  87. :precision="2"
  88. :controls="false"
  89. :append="'元'"
  90. @reschange="activity_price_change"
  91. />
  92. </el-form-item>
  93. </el-form>
  94. </el-col>
  95. <el-col :span="24" style="text-align: right">
  96. <el-button v-if="id !== '007'" type="primary" @click="submitForm"
  97. >保 存
  98. </el-button>
  99. <el-button @click="showModelThis = false">{{
  100. id == "007" ? "关 闭" : "取 消"
  101. }}</el-button>
  102. </el-col>
  103. </el-row>
  104. </el-card>
  105. </el-dialog>
  106. </template>
  107. <script>
  108. export default {
  109. name: "editMinorderForm",
  110. props: ["showModel", "sitem"],
  111. data() {
  112. const validate_activity_price = (rule, value, callback) => {
  113. if (value === "") {
  114. callback(new Error("活动价价不能为空!"));
  115. } else {
  116. callback();
  117. }
  118. };
  119. return {
  120. loading: false,
  121. showModelThis: this.showModel,
  122. ruleForm: {
  123. skuCode: "",
  124. good_name: "",
  125. activity_stock: "",
  126. moq_num: "",
  127. cost_price: "",
  128. sale_price: "",
  129. activity_price: "",
  130. },
  131. rulesThis: this.rules,
  132. rules: {
  133. activity_price: [
  134. {
  135. required: true,
  136. validator: validate_activity_price,
  137. trigger: "blur",
  138. },
  139. ],
  140. },
  141. };
  142. },
  143. watch: {
  144. showModel: function (val) {
  145. this.showModelThis = val;
  146. if (val) {
  147. this.initForm();
  148. }
  149. },
  150. showModelThis(val) {
  151. if (!val) {
  152. this.$emit("cancel");
  153. }
  154. },
  155. },
  156. methods: {
  157. async initForm() {
  158. this.loading = true;
  159. this.rulesThis = this.rules;
  160. await this.resetForm();
  161. this.loading = false;
  162. },
  163. async resetForm() {
  164. // 重置
  165. await this.$nextTick(() => {
  166. if (this.$refs.ruleForm) {
  167. this.$refs.ruleForm.resetFields();
  168. this.$refs.ruleForm.clearValidate();
  169. this.ruleForm = this.sitem
  170. ? JSON.parse(JSON.stringify(this.sitem))
  171. : {
  172. skuCode: "",
  173. good_name: "",
  174. activity_stock: "",
  175. moq_num: "",
  176. cost_price: "",
  177. sale_price: "",
  178. activity_price: "",
  179. };
  180. }
  181. });
  182. },
  183. activity_price_change(e) {
  184. this.ruleForm.activity_price = e + "";
  185. this.$refs.ruleForm.validateField("activity_price");
  186. },
  187. async submitForm() {
  188. await this.$refs.ruleForm.validate(async (valid) => {
  189. if (valid) {
  190. this.loading = true;
  191. let model = JSON.parse(JSON.stringify(this.ruleForm));
  192. this.showModelThis = false;
  193. // 刷新
  194. this.$emit("refresh", model);
  195. } else {
  196. console.log("error submit!!");
  197. return false;
  198. }
  199. });
  200. },
  201. },
  202. };
  203. </script>
  204. <style lang="scss" scoped>
  205. .sort {
  206. }
  207. </style>