wuHanReimbursementBusinessForm.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :close-on-click-modal="false"
  5. v-dialogDrag
  6. :visible.sync="visible">
  7. <el-form size="small" :model="inputForm" ref="inputForm" @keyup.enter.native="doSubmit()"
  8. label-width="120px" v-loading="loading" :class="method==='view'?'readonly':''" :disabled="method==='view'" @submit.native.prevent>
  9. <el-row :gutter="15">
  10. <el-col :span="12">
  11. <el-form-item prop="userId" :rules=" [{required: true, message: '人员不能为空', trigger: 'blur'}]" label="人员">
  12. <SelectUserTree
  13. ref="companyTree"
  14. :props="{
  15. value: 'id', // ID字段名
  16. label: 'name', // 显示名称
  17. children: 'children' // 子级字段名
  18. }"
  19. :url="`/sys/user/treeUserDataAllOffice?type=2`"
  20. :value="inputForm.userId"
  21. :clearable="true"
  22. :accordion="true"
  23. :disabled="method==='edit'"
  24. @getValue="(value) => {inputForm.userId=value}"/>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="12">
  28. <el-form-item label="年份" prop="year" :rules="[{required: true, message: '年份不能为空', trigger: 'blur'}]">
  29. <el-select v-model="inputForm.year" @change="selectYear(inputForm.year)" style="width:100%" placeholder="请选择">
  30. <el-option
  31. v-for="year in yearList"
  32. :key="year.id"
  33. :label="year.year"
  34. :value="year.year">
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="12" v-if="method !== 'read'">
  40. <el-form-item label="报销类型" prop="reimbursementType"
  41. :rules="[
  42. {required: true, message:'报销类型不能为空', trigger:'blur'}
  43. ]">
  44. <el-radio-group v-model="inputForm.reimbursementType">
  45. <el-radio v-for="item in $dictUtils.getDictList('reimbursement_type')" @change="selectReimbursementType(inputForm.reimbursementType)" :label="item.value" :key="item.id">{{item.label}}</el-radio>
  46. </el-radio-group>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="12" v-if="method !== 'read'">
  50. <el-form-item label="实发类型" prop="reimbursementFsalary"
  51. :rules="[
  52. {required: true, message:'请选择实发类型', trigger:'blur'}
  53. ]">
  54. <el-radio-group v-model="inputForm.reimbursementFsalary">
  55. <el-radio v-for="item in $dictUtils.getDictList('reimbursement_fsalary')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
  56. </el-radio-group>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="12" v-if="this.show">
  60. <el-form-item label="报销天数" prop="reimbursementDay" :rules="[{required: true, max: 10, message:'报销天数不能为空且只可为整数', trigger:'blur'}]">
  61. <el-input v-model="inputForm.reimbursementDay" class="bg-grey" size="small" placeholder="报销天数" style="width: 100%;" @keyup.native="inputForm.reimbursementDay = checkInputs(inputForm.reimbursementDay)"></el-input>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="12" v-if="this.show">
  65. <el-form-item label="剩余报销天数" prop="surplusReimbursementDay" :rules="[{ max: 10, trigger:'blur'}]">
  66. <el-input v-model="inputForm.surplusReimbursementDay" class="bg-grey" size="small" placeholder="剩余报销天数" style="width: 100%;" :disabled="true"></el-input>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="12">
  70. <el-form-item label="报销金额" prop="reimbursementAmount":rules="[{required: true, max: 10, message:'报销金额不可为空', max: 10,trigger:'blur'}]">
  71. <el-input id="reimbursementAmount" v-model="inputForm.reimbursementAmount" class="bg-grey" size="small" placeholder="报销金额" style="width: 100%;" v-bind:disabled="this.show" @keyup.native="inputForm.reimbursementAmount = checkReimbursementAmount(inputForm.reimbursementAmount)">
  72.   </el-input>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="12" v-if="this.show">
  76. <el-form-item label="日报销额度" prop="reimbursementQuotaDay":rules="[{max: 10,trigger:'blur'}]">
  77. <el-input v-model="inputForm.reimbursementQuotaDay" class="bg-grey" size="small" placeholder="日报销额度" style="width: 100%;" :disabled="true">
  78.   </el-input>
  79. </el-form-item>
  80. </el-col>
  81. <el-col :span="12">
  82. <el-form-item label="年报销额度" prop="reimbursementQuota":rules="[{max: 10,trigger:'blur'}]">
  83. <el-input v-model="inputForm.reimbursementQuota" class="bg-grey" size="small" placeholder="年报销额度" style="width: 100%;" :disabled="true">
  84.   </el-input>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="12">
  88. <el-form-item label="剩余可报额度" prop="remainReimbursementAmount" :rules="[{max: 10, trigger:'blur'}]">
  89. <el-input v-model="inputForm.remainReimbursementAmount" class="bg-grey" size="small" placeholder="剩余可报额度" style="width: 100%;" :disabled="true">
  90.   </el-input>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="12">
  94. <el-form-item label="业务可报额度" prop="canReimbursementAmount" :rules="[{max: 10, trigger:'blur'}]">
  95. <el-input v-model="inputForm.canReimbursementAmount" class="bg-grey" size="small" placeholder="业务可报额度" style="width: 100%;" :disabled="true">
  96.   </el-input>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="12">
  100. <el-form-item label="业务剩余可报额度" prop="surplusReimbursementAmount" :rules="[{max: 10, trigger:'blur'}]">
  101. <el-input v-model="inputForm.surplusReimbursementAmount" class="bg-grey" size="small" placeholder="业务剩余可报额度" style="width: 100%;" :disabled="true">
  102.   </el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="24">
  106. <el-form-item label="备注" prop="remarks" :rules="[{max: 255, trigger:'blur'}]">
  107. <el-input type="textarea" v-model="inputForm.remarks" oninput="if(value.length>255)value=value.slice(0,254)" placeholder="备注" > </el-input>
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. </el-form>
  112. <span slot="footer" class="dialog-footer">
  113. <el-button size="small" @click="visible = false" icon="el-icon-circle-close">关闭</el-button>
  114. <el-button size="small" type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
  115. </span>
  116. </el-dialog>
  117. </template>
  118. <script>
  119. import SelectUserTree from './treeReimbursementBuinessUserSelect'
  120. import ReimbursementBusiness from '@/api/reimbursementSys/wuHanReimbursementBusinessService'
  121. export default {
  122. data () {
  123. return {
  124. show: false,
  125. visible: false,
  126. loading: false,
  127. title: '',
  128. method: '',
  129. yearList: [],
  130. inputForm: {
  131. id: '',
  132. userId: '', // 人员id
  133. year: '', // 年份
  134. reimbursementType: '', // 报销类型
  135. reimbursementFsalary: '', // 实发类型
  136. reimbursementQuota: '', // 年报销额度
  137. reimbursementAmount: '', // 报销金额
  138. reimbursementQuotaDay: '', // 日报销额度
  139. canReimbursementAmount: '', // 业务可报销额度
  140. surplusReimbursementAmount: '', // 业务剩余可报销额度
  141. reimbursementDay: '', // 报销天数
  142. surplusReimbursementDay: '', // 剩余报销天数
  143. oldSurplusReimbursementDay: '', // 剩余报销天数(比较数据)
  144. remarks: '' // 备注
  145. }
  146. }
  147. },
  148. ReimbursementBusiness: null,
  149. created () {
  150. this.reimbursementBusiness = new ReimbursementBusiness()
  151. },
  152. mounted () {
  153. },
  154. components: {
  155. SelectUserTree
  156. },
  157. provide () {
  158. return {
  159. say: this.say
  160. }
  161. },
  162. methods: {
  163. checkInputs: function (num) {
  164. let str = num.toString()
  165. var len1 = str.substr(0, 1)
  166. var len2 = str.substr(1, 1)
  167. // eslint-disable-next-line eqeqeq
  168. if (str.length > 1 && len1 == 0 && len2 != '.') {
  169. str = str.substr(1, 1)
  170. }
  171. // eslint-disable-next-line eqeqeq
  172. if (len1 == '.') {
  173. str = ''
  174. }
  175. // eslint-disable-next-line no-useless-escape
  176. str = str.replace(/[^\d^]+/g, '') // 保留数字
  177. // 获取日报销额度
  178. let reimbursementQuotaDayNumber = this.inputForm.reimbursementQuotaDay
  179. if (reimbursementQuotaDayNumber) {
  180. var oldSurplusReimbursementDay = this.inputForm.oldSurplusReimbursementDay
  181. this.inputForm.reimbursementAmount = (str * reimbursementQuotaDayNumber).toString()
  182. this.inputForm.surplusReimbursementDay = (oldSurplusReimbursementDay - str).toString()
  183. }
  184. return str
  185. },
  186. checkReimbursementAmount: function (num) {
  187. let str = num.toString()
  188. var len1 = str.substr(0, 1)
  189. var len2 = str.substr(1, 1)
  190. // eslint-disable-next-line eqeqeq
  191. if (str.length > 1 && len1 == 0 && len2 != '.') {
  192. str = str.substr(1, 1)
  193. }
  194. // eslint-disable-next-line eqeqeq
  195. if (len1 == '.') {
  196. str = ''
  197. }
  198. // eslint-disable-next-line eqeqeq
  199. if (str.indexOf('.') != -1) {
  200. var str_ = str.substr(str.indexOf('.') + 1)
  201. // eslint-disable-next-line eqeqeq
  202. if (str_.indexOf('.') != -1) {
  203. str = str.substr(0, str.indexOf('.') + str_.indexOf('.') + 1)
  204. }
  205. if (str_.length > 2) {
  206. this.$message.warning(`金额小数点后只能输入两位,请正确输入!`)
  207. return (str = '')
  208. }
  209. }
  210. // eslint-disable-next-line no-useless-escape
  211. str = str.replace(/[^\d^\.]+/g, '') // 保留数字和小数点
  212. return str
  213. },
  214. say (userId) {
  215. // 根据用户id查询年份信息
  216. this.reimbursementBusiness.yearList({userId: userId, current: 1, size: -1}).then(({data}) => {
  217. this.yearList = data.records
  218. if (this.yearList.length > 0) {
  219. this.inputForm.year = this.yearList[0].year
  220. this.inputForm.reimbursementQuotaDay = this.yearList[0].reimbursementQuotaDay
  221. this.inputForm.reimbursementQuota = this.yearList[0].reimbursementQuota
  222. this.inputForm.remainReimbursementAmount = this.yearList[0].remainReimbursementAmount
  223. this.inputForm.surplusReimbursementDay = this.yearList[0].surplusReimbursementDay
  224. this.inputForm.oldSurplusReimbursementDay = this.yearList[0].surplusReimbursementDay
  225. // 获取日报销额度
  226. let reimbursementQuotaDayNumber = this.inputForm.reimbursementQuotaDay
  227. let reimbursementDayNumber = this.inputForm.reimbursementDay
  228. if (reimbursementQuotaDayNumber && reimbursementDayNumber) {
  229. var oldSurplusReimbursementDay = this.inputForm.oldSurplusReimbursementDay
  230. this.inputForm.reimbursementAmount = (reimbursementDayNumber * reimbursementQuotaDayNumber).toString()
  231. this.inputForm.surplusReimbursementDay = (oldSurplusReimbursementDay - reimbursementDayNumber).toString()
  232. }
  233. } else {
  234. this.inputForm.year = ''
  235. this.inputForm.reimbursementQuotaDay = ''
  236. this.inputForm.reimbursementQuota = ''
  237. this.inputForm.remainReimbursementAmount = ''
  238. this.inputForm.surplusReimbursementDay = ''
  239. this.inputForm.oldSurplusReimbursementDay = ''
  240. }
  241. })
  242. },
  243. selectReimbursementType (reimbursementType) {
  244. if (reimbursementType === '1') {
  245. // reimbursementAmount.isdisabled = true
  246. this.show = true
  247. } else {
  248. this.show = false
  249. }
  250. },
  251. selectYear (year) {
  252. for (var yearKey in this.yearList) {
  253. if (this.yearList[yearKey].year === year) {
  254. this.inputForm.reimbursementQuotaDay = this.yearList[yearKey].reimbursementQuotaDay
  255. this.inputForm.reimbursementQuota = this.yearList[yearKey].reimbursementQuota
  256. this.inputForm.remainReimbursementAmount = this.yearList[yearKey].remainReimbursementAmount
  257. // 获取日报销额度
  258. let reimbursementQuotaDayNumber = this.inputForm.reimbursementQuotaDay
  259. let reimbursementDayNumber = this.inputForm.reimbursementDay
  260. if (reimbursementQuotaDayNumber && reimbursementDayNumber) {
  261. this.inputForm.reimbursementAmount = (reimbursementDayNumber * reimbursementQuotaDayNumber).toString()
  262. }
  263. }
  264. }
  265. },
  266. init (method, obj) {
  267. this.method = method
  268. this.inputForm.businessCodeId = obj.businessCodeId
  269. this.inputForm.businessCode = obj.businessCode
  270. if (method === 'addBusinessInfo') {
  271. this.title = `新建报销信息`
  272. } else if (method === 'edit') {
  273. this.title = '修改人员信息'
  274. } else if (method === 'view') {
  275. this.title = '查看人员信息'
  276. }
  277. this.visible = true
  278. this.$nextTick(() => {
  279. this.inputForm.id = obj.id
  280. this.$refs['inputForm'].resetFields()
  281. if (method === 'edit' || method === 'view') { // 修改或者查看
  282. this.inputForm.id = obj
  283. this.loading = true
  284. this.reimbursementBusiness.queryById(this.inputForm.id).then(({data}) => {
  285. this.inputForm = this.recover(this.inputForm, data)
  286. this.selectReimbursementType(this.inputForm.reimbursementType)
  287. this.loading = false
  288. })
  289. }
  290. if (method === 'addBusinessInfo') { // 修改或者查看
  291. this.inputForm.businessCodeId = obj.businessCodeId
  292. this.loading = true
  293. this.reimbursementBusiness.getBusinessById(this.inputForm.businessCodeId).then(({data}) => {
  294. this.inputForm = this.recover(this.inputForm, data)
  295. this.selectReimbursementType(this.inputForm.reimbursementType)
  296. this.loading = false
  297. })
  298. }
  299. })
  300. },
  301. // 表单提交
  302. doSubmit () {
  303. this.$refs['inputForm'].validate((valid) => {
  304. if (valid) {
  305. this.loading = true
  306. this.inputForm.officeType = 1
  307. this.reimbursementBusiness.save(this.inputForm).then(({data}) => {
  308. this.loading = false
  309. this.visible = false
  310. this.$message.success(data)
  311. this.$emit('refreshDataList')
  312. }).catch(() => {
  313. this.loading = false
  314. })
  315. }
  316. })
  317. }
  318. }
  319. }
  320. </script>