setPartial.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :title="'设置部分字段'"
  5. :center="true"
  6. align="left"
  7. top="15vh"
  8. width="700px"
  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: -20px 0 0 0">
  17. <el-row :gutter="10">
  18. <el-col :span="24">
  19. <el-form
  20. ref="ruleForm"
  21. :model="ruleForm"
  22. status-icon
  23. :size="'mini'"
  24. :rules="rulesThis"
  25. label-width="110px"
  26. class="demo-ruleForm"
  27. >
  28. <el-form-item label="承诺回款时间" prop="paytime">
  29. <el-date-picker
  30. v-model="ruleForm.paytime"
  31. type="date"
  32. style="width: 100%"
  33. :disabled="false"
  34. value-format="yyyy-MM-dd"
  35. :picker-options="pickerOptions"
  36. placeholder="承诺回款时间"
  37. >
  38. </el-date-picker>
  39. </el-form-item>
  40. <el-form-item label="平台订单号" prop="platform_order">
  41. <el-input
  42. v-model="ruleForm.platform_order"
  43. placeholder="如:PO号"
  44. type="textarea"
  45. :rows="4"
  46. maxlength="2000"
  47. />
  48. </el-form-item>
  49. <el-form-item label="其他单号" prop="workNo">
  50. <el-input
  51. v-model="ruleForm.workNo"
  52. placeholder="如:业管单号"
  53. type="textarea"
  54. :rows="4"
  55. maxlength="2000"
  56. />
  57. </el-form-item>
  58. </el-form>
  59. </el-col>
  60. <el-col :span="24" style="text-align: right">
  61. <el-button type="primary" :size="'mini'" @click="submitForm"
  62. >保 存
  63. </el-button>
  64. <el-button :size="'mini'" @click="showModelThis = false"
  65. >取 消</el-button
  66. >
  67. </el-col>
  68. </el-row>
  69. </el-card>
  70. </el-dialog>
  71. </template>
  72. <script>
  73. import asyncRequest from "@/apis/service/sellOut/salesOrder";
  74. import resToken from "@/mixins/resToken";
  75. export default {
  76. name: "brand",
  77. props: ["showModel", "sitem"],
  78. mixins: [resToken],
  79. data() {
  80. return {
  81. loading: false,
  82. title: "添加单位",
  83. showModelThis: this.showModel,
  84. options: [],
  85. pickerOptions: {
  86. disabledDate(time) {
  87. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24;
  88. },
  89. },
  90. ruleForm: {
  91. orderCode: "",
  92. paytime: "",
  93. workNo: "",
  94. platform_order: "",
  95. },
  96. rulesThis: this.rules,
  97. rules: {
  98. paytime: [
  99. { required: true, message: "请选择承诺回款时间", trigger: "change" },
  100. ],
  101. platform_order: [
  102. { required: true, message: "请输入平台订单号", trigger: "blur" },
  103. ],
  104. workNo: [
  105. { required: true, message: "请输入其他单号", trigger: "blur" },
  106. ],
  107. },
  108. };
  109. },
  110. watch: {
  111. showModel: function (val) {
  112. this.showModelThis = val;
  113. if (val) {
  114. this.initForm();
  115. }
  116. },
  117. showModelThis(val) {
  118. if (!val) {
  119. this.$emit("cancel");
  120. }
  121. },
  122. },
  123. methods: {
  124. async initForm() {
  125. this.loading = true;
  126. this.rulesThis = this.rules;
  127. this.options = [];
  128. await this.resetForm();
  129. this.loading = false;
  130. },
  131. async resetForm() {
  132. // 重置
  133. await this.$nextTick(() => {
  134. if (this.$refs.ruleForm) {
  135. this.$refs.ruleForm.resetFields();
  136. this.$refs.ruleForm.clearValidate();
  137. const { orderCode, paytime, workNo, platform_order } = this.sitem;
  138. this.ruleForm = {
  139. orderCode: orderCode || "",
  140. paytime: paytime || "",
  141. workNo: workNo || "",
  142. platform_order: platform_order || "",
  143. };
  144. }
  145. });
  146. },
  147. async submitForm() {
  148. await this.$refs.ruleForm.validate(async (valid) => {
  149. if (valid) {
  150. this.loading = true;
  151. let model = JSON.parse(JSON.stringify(this.ruleForm));
  152. let res = (res = await asyncRequest.saleaddother(model));
  153. this.loading = false;
  154. if (res && res.code === 0) {
  155. this.$notify.success({
  156. title: "设置成功!",
  157. message: "",
  158. });
  159. this.showModelThis = false;
  160. // 刷新
  161. this.$emit("refresh");
  162. } else if (res && res.code >= 100 && res.code <= 104) {
  163. await this.logout();
  164. } else {
  165. this.$message.warning(res.message);
  166. }
  167. } else {
  168. console.log("error submit!!");
  169. return false;
  170. }
  171. });
  172. },
  173. },
  174. };
  175. </script>
  176. <style lang="scss" scoped>
  177. .brand {
  178. }
  179. </style>