addEditBargain.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :title="'申请议价'"
  5. :center="true"
  6. align="left"
  7. top="10vh"
  8. width="750px"
  9. :close-on-click-modal="false"
  10. :visible.sync="showModelThis"
  11. element-loading-text="拼命加载中"
  12. element-loading-spinner="el-icon-loading"
  13. element-loading-background="rgba(0, 0, 0, 0.8)"
  14. @close="showModelThis = false"
  15. >
  16. <el-card style="margin-top: -20px">
  17. <el-form
  18. ref="ruleForm"
  19. :model="ruleForm"
  20. status-icon
  21. :size="'mini'"
  22. :rules="rulesThis"
  23. label-width="80px"
  24. class="demo-ruleForm"
  25. >
  26. <el-row>
  27. <el-col :span="24">
  28. <el-form-item label="商品名称:">
  29. <el-input v-model="sitem.good_name" disabled />
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="3">
  33. <el-form-item label="图片:" style="margin: 0" label-width="44px">
  34. <img
  35. class="hover"
  36. v-viewer
  37. :src="sitem.good_img"
  38. alt=""
  39. v-if="sitem.good_img"
  40. style="width: 35px; height: 35px"
  41. />
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="4">
  45. <el-form-item label="单位:" label-width="50px">
  46. <el-input v-model="sitem.unit" disabled />
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="7">
  50. <el-form-item label="当前售价:">
  51. <el-input v-model="sitem.sale_price" disabled />
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="10">
  55. <el-form-item
  56. label="期望售价:"
  57. prop="bargain_price"
  58. label-width="95px"
  59. >
  60. <digital-input
  61. :values="ruleForm.bargain_price"
  62. :name="'ruleForm.bargain_price'"
  63. :placeholder="'期望售价'"
  64. :min="0"
  65. :disabled="false"
  66. :max="100000000000"
  67. :position="'right'"
  68. :precision="2"
  69. :size="'mini'"
  70. :controls="false"
  71. :append="'元'"
  72. @reschange="number_change($event, 'bargain_price')"
  73. />
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="16">
  77. <el-form-item label="型号:" style="margin: 0">
  78. <span v-for="(si, sii) in sitem.specinfo" :key="sii + 'spec'"
  79. ><span v-if="sii !== 0">--</span>
  80. <span>{{ si.spec_name }}[{{ si.spec_value_name }}]</span>
  81. </span>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="8" style="text-align: right">
  85. <el-button
  86. v-if="!isDetail"
  87. type="primary"
  88. :size="'mini'"
  89. @click="submitForm"
  90. >保 存
  91. </el-button>
  92. <el-button @click="showModelThis = false" :size="'mini'">{{
  93. isDetail ? "关 闭" : "取 消"
  94. }}</el-button>
  95. </el-col>
  96. </el-row>
  97. </el-form>
  98. </el-card>
  99. </el-dialog>
  100. </template>
  101. <script>
  102. import asyncRequest from "@/apis/service/sellOut/bargainList";
  103. import resToken from "@/mixins/resToken";
  104. export default {
  105. name: "Account",
  106. props: ["showModel", "sitem"],
  107. mixins: [resToken],
  108. data() {
  109. const validate_num = (rule, value, callback) => {
  110. if (value === "") {
  111. callback(new Error("不能为空!"));
  112. } else if (
  113. value === "0" ||
  114. value === "0." ||
  115. value === "0.0" ||
  116. value === "0.00"
  117. ) {
  118. callback(new Error("期望售价不能为零!"));
  119. } else {
  120. callback();
  121. }
  122. };
  123. return {
  124. roleList: [],
  125. loading: false,
  126. title: "添加账号",
  127. organizeList: [],
  128. showModelThis: this.showModel,
  129. ruleForm: {
  130. bargain_price: "0",
  131. },
  132. rulesThis: this.rules,
  133. rules: {
  134. bargain_price: [
  135. {
  136. required: true,
  137. validator: validate_num,
  138. trigger: "blur",
  139. },
  140. ],
  141. },
  142. };
  143. },
  144. watch: {
  145. showModel: function (val) {
  146. this.showModelThis = val;
  147. if (val) {
  148. this.initForm();
  149. }
  150. },
  151. showModelThis(val) {
  152. if (!val) {
  153. this.$emit("cancel");
  154. }
  155. },
  156. },
  157. mounted() {},
  158. methods: {
  159. itemidChange(e) {
  160. this.ruleForm.itemid = e;
  161. this.$refs.ruleForm.validateField("itemid");
  162. },
  163. async initForm() {
  164. this.loading = true;
  165. this.rulesThis = this.rules;
  166. await this.resetForm();
  167. this.loading = false;
  168. },
  169. number_change(e, key) {
  170. this.ruleForm[key] = e + "" || "0";
  171. this.$refs.ruleForm.validateField(key);
  172. },
  173. async resetForm() {
  174. // 重置
  175. await this.$nextTick(() => {
  176. if (this.$refs.ruleForm) {
  177. this.$refs.ruleForm.resetFields();
  178. this.$refs.ruleForm.clearValidate();
  179. this.ruleForm = {
  180. bargain_price: "0",
  181. };
  182. }
  183. });
  184. },
  185. async submitForm() {
  186. await this.$refs.ruleForm.validate(async (valid) => {
  187. if (valid) {
  188. this.loading = true;
  189. const { bargain_price } = JSON.parse(JSON.stringify(this.ruleForm));
  190. const { bidNo, sale_price } = this.sitem;
  191. if (sale_price * 100 === bargain_price * 100) {
  192. this.$message.warning("期望售价不能等于当前售价!");
  193. this.loading = false;
  194. return;
  195. }
  196. const model = {
  197. bidNo: bidNo,
  198. bargain_price: bargain_price, // 账号
  199. };
  200. let res = await asyncRequest.bargain_add(model);
  201. this.loading = false;
  202. if (res && res.code === 0) {
  203. this.$notify.success({
  204. title: "议价流程创建成功!",
  205. message: "",
  206. });
  207. this.showModelThis = false;
  208. // 刷新
  209. this.$emit("refresh");
  210. } else if (res && res.code >= 100 && res.code <= 104) {
  211. await this.logout();
  212. } else {
  213. this.$message.warning(res.message);
  214. }
  215. } else {
  216. console.log("error submit!!");
  217. return false;
  218. }
  219. });
  220. },
  221. },
  222. };
  223. </script>
  224. <style lang="scss" scoped>
  225. .account {
  226. }
  227. </style>