supplier_exam.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <el-form ref="formRef" class="supplier-form" size="mini" label-width="80px" :model="formData" :rules="rules">
  3. <el-form-item label="审核状态" prop="status">
  4. <el-select v-model="formData.status" style="width:100%">
  5. <el-option v-for="opt in statusOptions" :key="opt.value" :value="opt.value" :label="opt.label" />
  6. </el-select>
  7. </el-form-item>
  8. <el-form-item label="审核备注" prop="remark">
  9. <el-input v-model="formData.remark" />
  10. </el-form-item>
  11. <template v-if="displayExpressField">
  12. <el-form-item label="收货人" prop="contactor">
  13. <el-input v-model="formData.contactor" />
  14. </el-form-item>
  15. <el-form-item label="联系电话" prop="mobile">
  16. <el-input v-model="formData.mobile" max-length="11" />
  17. </el-form-item>
  18. <el-form-item label="退货地址" prop="addr_code">
  19. <select-area
  20. :placeholder="'省/市/区'"
  21. :value="formData.addr_code"
  22. :is-detail="true"
  23. :size="'mini'"
  24. @selectChange="addr_selectChange"
  25. />
  26. </el-form-item>
  27. <el-form-item label="详细地址" prop="addr">
  28. <el-input v-model="formData.addr" placeholder="详细地址" />
  29. </el-form-item>
  30. </template>
  31. <el-form-item>
  32. <div style="width:100%;display:flex;justify-content:flex-end">
  33. <el-button type="primary" @click="submit">提交</el-button>
  34. </div>
  35. </el-form-item>
  36. </el-form>
  37. </template>
  38. <script>
  39. import { isMobile } from '@/utils/validate'
  40. const validatename = (rule, value, callback) => {
  41. if (value === '') {
  42. callback(new Error('收件人不能为空!'))
  43. } else {
  44. callback()
  45. }
  46. }
  47. const validatemobile = (rule, value, callback) => {
  48. if (value === '') {
  49. callback(new Error('手机号不能为空!'))
  50. } else {
  51. if (!isMobile(value)) {
  52. callback(new Error('手机号格式不正确!'))
  53. } else {
  54. callback()
  55. }
  56. }
  57. }
  58. export default {
  59. name: 'SupplierExam',
  60. mixins: [],
  61. props: [],
  62. data() {
  63. return {
  64. formData: {
  65. status: '4',
  66. remark: '',
  67. contactor: '',
  68. mobile: '',
  69. addr_code: '',
  70. addr: ''
  71. },
  72. statusOptions: [
  73. { value: '4', label: '通过' }, // -> 待客户退货
  74. { value: '2', label: '驳回' } // -> 待采购审核
  75. ]
  76. }
  77. },
  78. computed: {
  79. displayExpressField() {
  80. return this.formData.status === '4'
  81. },
  82. rules() {
  83. const { status } = this.formData
  84. return ({
  85. addr: [
  86. {
  87. required: true,
  88. trigger: 'change',
  89. message: '请输入详细地址'
  90. }
  91. ],
  92. status: [
  93. {
  94. required: true,
  95. trigger: 'change',
  96. message: '请选择审核状态'
  97. }
  98. ],
  99. remark: [
  100. {
  101. required: status === '2',
  102. trigger: 'change',
  103. message: '请输入备注'
  104. }
  105. ],
  106. contactor: [
  107. {
  108. required: true,
  109. trigger: 'blur',
  110. validator: validatename
  111. }
  112. ],
  113. mobile: [
  114. {
  115. required: true,
  116. trigger: 'blur',
  117. validator: validatemobile
  118. }
  119. ],
  120. addr_code: [
  121. {
  122. type: 'array',
  123. required: true,
  124. trigger: 'change',
  125. message: '请选择省市区'
  126. }
  127. ]
  128. })
  129. }
  130. },
  131. mounted() {
  132. },
  133. methods: {
  134. addr_selectChange(e) {
  135. this.formData.addr_code = e || []
  136. this.$refs.formRef.validateField('addr_code')
  137. },
  138. submit() {
  139. this.$refs.formRef.validate(isValid => {
  140. if (!isValid) return
  141. const { addr_code } = this.formData
  142. const params = {
  143. ...this.formData,
  144. addr_code: addr_code ? addr_code.join(',') : ''
  145. }
  146. this.$emit('changeStatus', params)
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .supplier-form{
  154. ::v-deep(.el-form-item){
  155. width: 600px;
  156. }
  157. }
  158. </style>