supplier_feedback.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <el-form
  3. ref="ruleForm"
  4. :loading="loading"
  5. :model="ruleForm"
  6. status-icon
  7. :rules="rulesThis"
  8. label-width="100px"
  9. style="width: 100%"
  10. class="demo-ruleForm"
  11. >
  12. <el-row>
  13. <el-row>
  14. <el-col :span="12">
  15. <el-form-item label="是否同意" prop="is_th">
  16. <el-select
  17. style="width: 100%"
  18. :disabled="
  19. !(status == '1' && powers.some((item) => item == '046'))
  20. "
  21. v-model="ruleForm.is_th"
  22. placeholder="是否同意退回"
  23. >
  24. <el-option
  25. v-for="item in is_th_options"
  26. :key="item.value"
  27. :label="item.label"
  28. :value="item.value"
  29. >
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="12">
  35. <el-form-item label="反馈备注" prop="remark">
  36. <el-input
  37. type="textarea"
  38. placeholder="反馈备注"
  39. :disabled="
  40. !(status == '1' && powers.some((item) => item == '046'))
  41. "
  42. v-model="ruleForm.remark"
  43. maxlength="250"
  44. show-word-limit
  45. />
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. <el-row v-if="ruleForm.is_th === '1'">
  50. <el-col :span="12">
  51. <el-form-item label="收件人" prop="contactor">
  52. <el-input
  53. :disabled="
  54. !(status == '1' && powers.some((item) => item == '046'))
  55. "
  56. v-model="ruleForm.contactor"
  57. placeholder="收件人"
  58. ></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="12">
  62. <el-form-item label="收件人电话" prop="mobile">
  63. <el-input
  64. :disabled="
  65. !(status == '1' && powers.some((item) => item == '046'))
  66. "
  67. v-model="ruleForm.mobile"
  68. placeholder="收件人电话"
  69. ></el-input>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="12">
  73. <el-form-item label="地址省市区" prop="addr_code">
  74. <select-area
  75. :placeholder="'省市区'"
  76. :disabled="
  77. !(status == '1' && powers.some((item) => item == '046'))
  78. "
  79. :value="ruleForm.addr_code"
  80. :is-detail="id !== 'add'"
  81. @selectChange="selectAreaAddr_code"
  82. />
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="12">
  86. <el-form-item label="详细地址" prop="addr">
  87. <el-input
  88. v-model="ruleForm.addr"
  89. :disabled="
  90. !(status == '1' && powers.some((item) => item == '046'))
  91. "
  92. placeholder="详细地址"
  93. ></el-input>
  94. </el-form-item>
  95. </el-col>
  96. </el-row>
  97. <el-col
  98. :span="24"
  99. style="text-align: right;padding:0 0 20px 0;"
  100. v-if="status == '1' && powers.some((item) => item == '046')"
  101. >
  102. <el-button type="primary" :size="'mini'" @click="submitForm"
  103. >保 存</el-button
  104. >
  105. </el-col>
  106. </el-row>
  107. </el-form>
  108. </template>
  109. <script>
  110. import { isMobile } from "@/utils/validate";
  111. import asyncRequest from "@/apis/service/sellOut/zixunOrder";
  112. import resToken from "@/mixins/resToken";
  113. export default {
  114. name: "zixunOrderDetail",
  115. props: ["id", "showModelThis", "newTime", "sitem"],
  116. mixins: [resToken],
  117. data() {
  118. const validatemobile = (rule, value, callback) => {
  119. if (value === "") {
  120. callback(new Error("手机号不能为空!"));
  121. } else {
  122. if (!isMobile(value)) {
  123. callback(new Error("手机号格式不正确!"));
  124. } else {
  125. callback();
  126. }
  127. }
  128. };
  129. return {
  130. loading: false,
  131. status: "",
  132. showModelThis: this.showModel,
  133. ruleForm: {
  134. is_th: "1", //是否同意退回
  135. remark: "", //反馈备注
  136. addr_code: [], //退货地址
  137. addr: "", //退货详细地址
  138. contactor: "", //收件人
  139. mobile: "", //收件人电话
  140. wsm_code: "-",
  141. },
  142. rulesThis: this.rules,
  143. // 验证规则
  144. rules: {
  145. is_th: [
  146. {
  147. required: true,
  148. trigger: "change",
  149. message: "请选择是否同意退回",
  150. },
  151. ],
  152. remark: [
  153. {
  154. required: true,
  155. message: "请输入反馈备注",
  156. trigger: "blur",
  157. },
  158. ],
  159. addr_code: [
  160. {
  161. type: "array",
  162. required: true,
  163. message: "请选择退回地址所在省/市/区",
  164. trigger: "change",
  165. },
  166. ],
  167. addr: [
  168. {
  169. required: true,
  170. message: "请输入详细退货地址",
  171. trigger: "blur",
  172. },
  173. ],
  174. contactor: [
  175. {
  176. required: true,
  177. message: "请输入收件人",
  178. trigger: "blur",
  179. },
  180. ],
  181. mobile: [
  182. {
  183. required: true,
  184. trigger: "blur",
  185. validator: validatemobile,
  186. },
  187. ],
  188. },
  189. is_th_options: [
  190. {
  191. value: "1",
  192. label: "同意退回",
  193. },
  194. {
  195. value: "0",
  196. label: "拒绝退回",
  197. },
  198. ],
  199. };
  200. },
  201. computed: {
  202. powers() {
  203. let tran =
  204. this.$store.getters.btnList.find(
  205. (item) => item.menu_route == "zixunOrderDetail"
  206. ) || {};
  207. if (tran && tran.action && tran.action.length > 0) {
  208. return tran.action;
  209. } else {
  210. return [];
  211. }
  212. },
  213. },
  214. mounted() {
  215. this.initForm();
  216. },
  217. watch: {
  218. newTime: function (val) {
  219. if (val) {
  220. this.initForm();
  221. }
  222. },
  223. },
  224. methods: {
  225. closeAdd() {
  226. this.showModelThis = false;
  227. },
  228. async initForm() {
  229. this.status = "";
  230. this.loading = true;
  231. this.rulesThis = this.rules;
  232. await this.resetForm();
  233. this.loading = false;
  234. },
  235. async resetForm() {
  236. // 重置
  237. await this.$nextTick(() => {
  238. if (this.$refs.ruleForm) {
  239. this.$refs.ruleForm.resetFields();
  240. this.$refs.ruleForm.clearValidate();
  241. const {
  242. contactor,
  243. is_th,
  244. mobile,
  245. addr_code,
  246. addr,
  247. returnCode,
  248. gys_remark,
  249. status,
  250. } = this.sitem;
  251. let list = [];
  252. this.status = status;
  253. if (
  254. addr_code &&
  255. addr_code.area_code &&
  256. addr_code.city_code &&
  257. addr_code.provice_code
  258. ) {
  259. list.push(addr_code.provice_code);
  260. list.push(addr_code.city_code);
  261. list.push(addr_code.area_code);
  262. }
  263. this.ruleForm = {
  264. returnCode: returnCode || "",
  265. is_th: is_th || "1", //是否同意退回
  266. remark: gys_remark || "", //反馈备注
  267. addr_code: list.length === 3 ? list : [], //退货地址
  268. addr: addr || "", //退货详细地址
  269. contactor: contactor || "", //收件人
  270. mobile: mobile || "", //收件人电话
  271. wsm_code: "-",
  272. };
  273. console.log(this.ruleForm);
  274. }
  275. });
  276. },
  277. async submitForm() {
  278. await this.$refs.ruleForm.validate(async (valid) => {
  279. if (valid) {
  280. let model = JSON.parse(JSON.stringify(this.ruleForm));
  281. this.loading = true;
  282. let res = await asyncRequest.aftergys(model);
  283. this.loading = false;
  284. if (res && res.code === 0) {
  285. this.$notify.success({
  286. title: "提交成功!",
  287. message: "",
  288. });
  289. this.$emit("refresh", false);
  290. } else if (res && res.code >= 100 && res.code <= 104) {
  291. await this.logout();
  292. } else {
  293. this.$message.warning(res.message);
  294. }
  295. } else {
  296. console.log("error submit!!");
  297. return false;
  298. }
  299. });
  300. },
  301. //退货省市区
  302. selectAreaAddr_code(e) {
  303. this.ruleForm.addr_code = e;
  304. this.$refs.ruleForm.validateField("addr_code");
  305. },
  306. },
  307. };
  308. </script>