settlementModifyModal.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div>
  3. <a-modal
  4. centered
  5. wrapClassName="settlementModifyModal-modal"
  6. :footer="null"
  7. :maskClosable="false"
  8. title="修改结算方式"
  9. v-model="isshow"
  10. @cancle="handleBack"
  11. :width="650">
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <a-form-model
  14. id="settlementModifyModal-form"
  15. ref="ruleForm"
  16. :model="form"
  17. :rules="rules"
  18. :label-col="formItemLayout.labelCol"
  19. :wrapper-col="formItemLayout.wrapperCol"
  20. >
  21. <a-row :gutter="24">
  22. <a-col :span="20">
  23. <a-form-model-item label="当前结算方式">
  24. {{ settleInfo&&settleInfo.settleType=='CREDIT'?'授信结算':'按月结算' }}
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :span="20">
  28. <a-form-model-item label="结算方式" prop="settleType">
  29. <a-select
  30. style="background-color: none;"
  31. placeholder="请选择结算方式"
  32. id="settlementModifyModal-settleType"
  33. allowClear
  34. v-model="form.settleType"
  35. >
  36. <a-select-option v-for="item in settlementTypeList" :key="item.code" :value="item.code" :disabled="settleInfo&&settleInfo.settleType==item.code?true:false">{{ item.name }}</a-select-option>
  37. </a-select>
  38. </a-form-model-item>
  39. </a-col>
  40. <a-row v-if="form.settleType=='CREDIT'">
  41. <a-col :span="20">
  42. <a-form-model-item label="授信额度" prop="creditLimit">
  43. <a-input-number
  44. id="settlementModifyModal-creditLimit"
  45. v-model="form.creditLimit"
  46. :precision="2"
  47. :min="0.01"
  48. :max="999999"
  49. placeholder="请输入正数(最多允许两位小数)"
  50. style="width: 100%;display: inline-block;" />
  51. </a-form-model-item>
  52. </a-col>
  53. <a-col :span="4"> <span style="display: inline-block; padding: 10px;">元</span></a-col>
  54. </a-row>
  55. <a-col :span="20" v-if="form.settleType=='MONTH'">
  56. <a-form-model-item label="结算日期" prop="settleDay" >
  57. <div style="display: flex;padding: 0;align-items: center;">
  58. <span style="display: inline-block;margin-right: 10px;">每月</span>
  59. <a-select
  60. style="background-color: none;width: 65%"
  61. placeholder="请选择结算日期"
  62. id="settlementModifyModal-settleDay"
  63. allowClear
  64. v-model="form.settleDay"
  65. >
  66. <a-select-option v-for="item in dateList" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
  67. </a-select>
  68. <span style="display: inline-block;margin-left: 10px;">号</span>
  69. </div>
  70. </a-form-model-item>
  71. </a-col>
  72. <a-row v-if="form.settleType=='CREDIT'">
  73. <a-col :span="20">
  74. <a-form-model-item label="结算提醒金额" prop="creditWarnLimit" >
  75. <a-input-number
  76. id="settlementModifyModal-creditWarnLimit"
  77. v-model="form.creditWarnLimit"
  78. :precision="2"
  79. :min="0.01"
  80. :max="form.creditLimit-0.1"
  81. placeholder="请输入正数(最多允许两位小数)"
  82. style="width: 100%;display: inline-block;" />
  83. </a-form-model-item>
  84. </a-col>
  85. <a-col :span="4"> <span style="display: inline-block; padding: 10px;">元</span></a-col>
  86. </a-row>
  87. <a-col :span="20" v-if="form.settleType=='MONTH'">
  88. <a-form-model-item label="结算提醒" prop="warnBeforeDays" >
  89. <div style="display: flex;padding: 0;align-items: center;">
  90. <span style="display: inline-block;margin-right: 10px;">提前</span>
  91. <a-select
  92. style="background-color: none;width: 65%;"
  93. placeholder="请选择结算提醒日期"
  94. id="settlementModifyModal-warnBeforeDays"
  95. allowClear
  96. v-model="form.warnBeforeDays"
  97. >
  98. <a-select-option v-for="item in dateTXList" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
  99. </a-select>
  100. <span style="display: inline-block;margin-left: 10px;">天开始提醒</span>
  101. </div>
  102. </a-form-model-item>
  103. </a-col>
  104. <a-col :span="20">
  105. <a-form-model-item :label="form.settleType=='CREDIT'?'超过授信额度':'超期未结算'" v-if="form.settleType">
  106. <a-checkbox id="settlementModifyModal-onChange" :checked="form.limitFlag==1">
  107. 限制汽车修理厂无法使用数字货架
  108. </a-checkbox>
  109. </a-form-model-item>
  110. </a-col>
  111. </a-row>
  112. <a-form-model-item :label-col="{span: 0}" :wrapper-col="{span: 24}" style="text-align: center;">
  113. <a-button type="primary" @click="handleSubmit()" :style="{ marginRight: '8px' }" id="settlementModifyModal-handleSubmit">保存</a-button>
  114. <a-button :style="{ marginLeft: '8px' }" @click="handleBack" id="settlementModifyModal-handleBack">取消</a-button>
  115. </a-form-model-item>
  116. </a-form-model>
  117. </a-spin>
  118. </a-modal>
  119. </div>
  120. </template>
  121. <script>
  122. import { STable, VSelect, Upload } from '@/components'
  123. import { shelfSettleRuleSave } from '@/api/shelf.js'
  124. export default {
  125. name: 'SettlementModifyModal',
  126. components: {
  127. STable, VSelect, Upload
  128. },
  129. props: {
  130. visible: {
  131. type: Boolean,
  132. default: false
  133. },
  134. shelfInfo: {
  135. type: Object,
  136. default: function () {
  137. return {}
  138. }
  139. },
  140. settleInfo: {
  141. type: Object,
  142. default: function () {
  143. return {}
  144. }
  145. }
  146. },
  147. data () {
  148. return {
  149. spinning: false,
  150. isshow: this.visible,
  151. roleList: [],
  152. formItemLayout: {
  153. labelCol: { span: 10 },
  154. wrapperCol: { span: 14 }
  155. },
  156. settlementTypeList: [{ code: 'MONTH', name: '按月结算' }, { code: 'CREDIT', name: '授信结算' }],
  157. dateList: [{ id: 1, name: 1 }, { id: 2, name: 2 }, { id: 3, name: 3 }, { id: 4, name: 4 }, { id: 5, name: 5 }, { id: 6, name: 6 }, { id: 7, name: 7 }, { id: 8, name: 8 }, { id: 9, name: 9 }, { id: 10, name: 10 }, { id: 11, name: 11 }, { id: 12, name: 12 }, { id: 13, name: 13 }, { id: 14, name: 14 }, { id: 15, name: 15 }, { id: 16, name: 16 }, { id: 17, name: 17 }, { id: 18, name: 18 }, { id: 19, name: 19 }, { id: 20, name: 20 }, { id: 21, name: 21 }, { id: 22, name: 22 }, { id: 23, name: 23 }, { id: 24, name: 24 }, { id: 25, name: 25 }],
  158. dateTXList: [{ id: 1, name: 1 }, { id: 2, name: 2 }, { id: 3, name: 3 }, { id: 4, name: 4 }, { id: 5, name: 5 }, { id: 6, name: 6 }, { id: 7, name: 7 }, { id: 8, name: 8 }, { id: 9, name: 9 }, { id: 10, name: 10 }],
  159. form: {
  160. settleType: undefined, // 结算方式
  161. creditLimit: '', // 授信额度
  162. creditWarnLimit: '', // 结算提醒金额
  163. settleDay: undefined, // 每月结算日
  164. warnBeforeDays: undefined, // 结算提醒提前天数
  165. limitFlag: ''// 是否限制使用
  166. },
  167. rules: {
  168. settleType: [ { required: true, message: '请选择结算方式', trigger: 'change' } ],
  169. creditLimit: [ { required: true, message: '请输入授信额度', trigger: 'blur' } ],
  170. creditWarnLimit: [{ required: true, message: '请输入结算提醒金额', trigger: 'blur' }],
  171. settleDay: [ { required: true, message: '请选择每月结算日期', trigger: 'change' } ],
  172. warnBeforeDays: [ { required: true, message: '请选择每月结算提醒提前的日期', trigger: 'change' } ]
  173. }
  174. }
  175. },
  176. methods: {
  177. // 过滤空格
  178. filterEmpty () {
  179. let str = this.form.name
  180. str = str.replace(/\ +/g, '')
  181. str = str.replace(/[ ]/g, '')
  182. str = str.replace(/[\r\n]/g, '')
  183. this.form.name = str
  184. },
  185. // 改变货架归属
  186. changeRadio (e) {
  187. this.form.loginFlag = e.target.value
  188. console.log(e.target.value, '=========')
  189. },
  190. // 保存提交
  191. handleSubmit () {
  192. const _this = this
  193. this.$refs.ruleForm.validate(valid => {
  194. if (valid) {
  195. const params = Object.assign({}, _this.form)
  196. if (params.limitFlag == '') {
  197. params.limitFlag = 0
  198. }
  199. if (this.shelfInfo) {
  200. console.log(this.shelfInfo, 'this.nowData')
  201. params.shelfSn = this.shelfInfo.shelfSn
  202. params.storeSn = this.shelfInfo.storeSn
  203. params.dealerSn = this.shelfInfo.dealerSn
  204. }
  205. if (this.settleInfo) {
  206. params.bondAmount = this.settleInfo.bondAmount
  207. params.bondFlag = this.settleInfo.bondFlag
  208. params.id = this.settleInfo.id
  209. }
  210. _this.spinning = true
  211. shelfSettleRuleSave(params).then(res => {
  212. if (res.status == 200) {
  213. _this.$message.success(res.message)
  214. _this.$emit('close', params.settleType)
  215. setTimeout(function () {
  216. _this.isshow = false
  217. _this.spinning = false
  218. }, 300)
  219. } else {
  220. _this.spinning = false
  221. }
  222. })
  223. } else {
  224. console.log('error submit!!')
  225. return false
  226. }
  227. })
  228. },
  229. handleBack () {
  230. this.form = {
  231. settleType: undefined, // 结算方式
  232. creditLimit: '', // 授信额度
  233. creditWarnLimit: '', // 结算提醒金额
  234. settleDay: undefined, // 每月结算日
  235. warnBeforeDays: undefined, // 结算提醒提前天数
  236. limitFlag: 0 // 是否限制使用
  237. }
  238. this.$refs.ruleForm.resetFields()
  239. this.$emit('close')
  240. }
  241. },
  242. watch: {
  243. visible (newValue, oldValue) {
  244. this.isshow = newValue
  245. },
  246. isshow (newValue, oldValue) {
  247. if (!newValue) {
  248. this.$refs.ruleForm.resetFields()
  249. this.$emit('close')
  250. }
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="less">
  256. .settlementModifyModal-modal{
  257. .ant-input-number-handler-wrap{
  258. display: none;
  259. }
  260. }
  261. </style>