baseModal.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <a-modal
  3. v-model="opened"
  4. :title="title"
  5. centered
  6. :maskClosable="false"
  7. :width="600"
  8. :footer="null"
  9. @cancel="cancel"
  10. >
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="chooseCustom-form"
  14. ref="ruleForm"
  15. :model="form"
  16. :rules="rules"
  17. :label-col="formItemLayout.labelCol"
  18. :wrapper-col="formItemLayout.wrapperCol">
  19. <a-form-model-item label="客户名称" prop="dealerSn">
  20. <dealerSubareaScopeList id="manualEntryForm-dealer" :disabled="!!itemSn" ref="settleClientName" @change="custChange" />
  21. </a-form-model-item>
  22. <a-form-model-item label="借贷类型" prop="changeType">
  23. <v-select
  24. v-model="form.changeType"
  25. ref="changeType"
  26. showType="radio"
  27. id="manualEntryForm-type"
  28. code="VERIFY_ACCOUNT_CHANGE_TYPE"
  29. placeholder="请选择借贷类型"
  30. allowClear></v-select>
  31. </a-form-model-item>
  32. <a-form-model-item label="借贷金额" prop="changeAmount">
  33. <a-input-number
  34. id="manualEntryForm-amount"
  35. :min="0"
  36. :max="99999999"
  37. v-model.trim="form.changeAmount"
  38. allowClear
  39. style="width:200px;"
  40. placeholder="请输入借贷金额"/>
  41. </a-form-model-item>
  42. <a-form-model-item label="备注">
  43. <a-textarea :rows="4" :maxLength="100" placeholder="请输入备注(最多100个字符)" v-model="form.remarks"></a-textarea>
  44. </a-form-model-item>
  45. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;margin-top: 30px;">
  46. <a-button @click="cancel" style="margin-right: 15px" id="chooseCustom-btn-back">取消</a-button>
  47. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
  48. </a-form-model-item>
  49. </a-form-model>
  50. </a-spin>
  51. </a-modal>
  52. </template>
  53. <script>
  54. import { commonMixin } from '@/utils/mixin'
  55. import { VSelect } from '@/components'
  56. // 组件
  57. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  58. import { verifyAccountChangeSave, verifyAccountChangeDetail } from '@/api/verifyAccountChange.js'
  59. export default {
  60. name: 'ASBaseModal',
  61. mixins: [commonMixin],
  62. components: { VSelect, dealerSubareaScopeList },
  63. props: {
  64. show: [Boolean],
  65. itemSn: {
  66. type: String,
  67. default: ''
  68. }
  69. },
  70. data () {
  71. let checkPending
  72. const checkAmount = (rule, value, callback) => {
  73. clearTimeout(checkPending)
  74. if (!value && value != 0) {
  75. return callback(new Error('请输入借贷金额'))
  76. }
  77. checkPending = setTimeout(() => {
  78. if (value <= 0) {
  79. callback(new Error('借贷金额必需大于0'))
  80. } else {
  81. callback()
  82. }
  83. }, 500)
  84. }
  85. return {
  86. opened: this.show,
  87. spinning: false,
  88. disabled: false,
  89. title: '调账',
  90. confirmLoading: false,
  91. formItemLayout: {
  92. labelCol: { span: 4 },
  93. wrapperCol: { span: 18 }
  94. },
  95. form: {
  96. dealerSn: undefined,
  97. dealerName: undefined,
  98. changeType: undefined,
  99. changeAmount: undefined,
  100. remarks: ''
  101. },
  102. rules: {
  103. dealerSn: [ { required: true, message: '请选择客户', trigger: ['change', 'blur'] } ],
  104. changeType: [ { required: true, message: '请选择借贷类型', trigger: ['change', 'blur'] } ],
  105. changeAmount: [
  106. { required: true, validator: checkAmount, trigger: ['change', 'blur'] }
  107. ]
  108. }
  109. }
  110. },
  111. methods: {
  112. // 客户
  113. custChange (v) {
  114. if (v && v.key) {
  115. this.form.dealerSn = v.key
  116. this.form.dealerName = v.row ? v.row.dealerName : ''
  117. } else {
  118. this.form.dealerSn = ''
  119. this.form.dealerName = ''
  120. }
  121. },
  122. // 保存
  123. handleSubmit (e) {
  124. e.preventDefault()
  125. const _this = this
  126. this.$refs.ruleForm.validate(valid => {
  127. if (valid) {
  128. _this.salesSaveFun()
  129. } else {
  130. return false
  131. }
  132. })
  133. },
  134. // 新建或编辑销售单
  135. salesSaveFun () {
  136. const _this = this
  137. const form = JSON.parse(JSON.stringify(_this.form))
  138. _this.spinning = true
  139. verifyAccountChangeSave(form).then(res => {
  140. if (res.status == 200) {
  141. _this.$message.success(res.message)
  142. this.$emit('ok', res.data)
  143. // 选择审批人员
  144. _this.cancel()
  145. }
  146. _this.spinning = false
  147. })
  148. },
  149. // 详情
  150. getDetail () {
  151. this.title = '编辑调账'
  152. this.spinning = true
  153. this.confirmLoading = true
  154. verifyAccountChangeDetail({ sn: this.itemSn }).then(res => {
  155. if (res.status == 200) {
  156. const data = res.data
  157. this.form = Object.assign(this.form, data)
  158. // 回显客户
  159. if (this.form.dealerSn) {
  160. this.$nextTick(() => {
  161. this.$refs.settleClientName.getDetail(this.form.dealerSn)
  162. })
  163. }
  164. } else {
  165. this.$refs.ruleForm.resetFields()
  166. }
  167. this.spinning = false
  168. this.confirmLoading = false
  169. })
  170. },
  171. cancel () {
  172. this.opened = false
  173. if (this.$refs.settleClientName) {
  174. this.$refs.settleClientName.resetForm()
  175. }
  176. this.$refs.ruleForm.resetFields()
  177. this.$emit('cancel')
  178. },
  179. pageInit () {
  180. this.$nextTick(() => {
  181. this.$refs.ruleForm.resetFields()
  182. if (this.$refs.settleClientName) {
  183. this.$refs.settleClientName.resetForm()
  184. }
  185. })
  186. this.form = {
  187. dealerSn: undefined,
  188. dealerName: undefined,
  189. changeType: undefined,
  190. changeAmount: undefined,
  191. remarks: ''
  192. }
  193. // 编辑页
  194. if (this.itemSn) {
  195. this.getDetail()
  196. }
  197. }
  198. },
  199. watch: {
  200. show (newValue, oldValue) {
  201. this.opened = newValue
  202. if (newValue) {
  203. this.pageInit()
  204. }
  205. }
  206. }
  207. }
  208. </script>