RevenueForm.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" backUrl="/pages/revenue/RevenueList" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">{{title}}</block>
  6. </cu-custom>
  7. <form @submit="formSubmit" class="cu-list menu">
  8. <view class="cu-form-group margin-top">
  9. <view class="title">
  10. <text class="red-color ">* </text> 企业
  11. </view>
  12. <jp-picker v-model="inputForm.qiId" rangeKey="label" rangeValue="value" :range="parkList">
  13. </jp-picker>
  14. </view>
  15. <view class="cu-form-group margin-top">
  16. <view class="title">
  17. <text class="red-color ">* </text> 类别
  18. </view>
  19. <jp-picker v-model="inputForm.lb" rangeKey="label" rangeValue="value"
  20. :range="$dictUtils.getDictList('s_lb')">
  21. <view class="picker">
  22. {{$dictUtils.getDictLabel('s_lb', inputForm.lb ,'请选择')}}
  23. </view>
  24. </jp-picker>
  25. </view>
  26. <view class="cu-form-group margin-top">
  27. <view class="title">
  28. <text class="red-color ">* </text> 税源办
  29. </view>
  30. <jp-picker v-model="inputForm.des3" rangeKey="label" rangeValue="value"
  31. :range="$dictUtils.getDictList('yes_no')">
  32. <view class="picker">
  33. {{$dictUtils.getDictLabel('yes_no', inputForm.des3 ,'请选择')}}
  34. </view>
  35. </jp-picker>
  36. </view>
  37. <view class="cu-form-group margin-top" v-if="this.inputForm.des3 !=='1'">
  38. <view class="title">
  39. <text class="red-color ">* </text> 月份
  40. </view>
  41. <picker mode="date" :value="inputForm.des1" fields="month" @change="DateChange">
  42. <view class="picker">
  43. {{inputForm.des1}}
  44. </view>
  45. </picker>
  46. </view>
  47. <view class="cu-form-group margin-top" v-if="this.inputForm.des3 ==='1'">
  48. <view class="title">
  49. <text class="red-color ">* </text> 开始月份
  50. </view>
  51. <picker mode="date" :value="inputForm.des1" fields="month" @change="DateChange">
  52. <view class="picker">
  53. {{inputForm.des1}}
  54. </view>
  55. </picker>
  56. </view>
  57. <view class="cu-form-group margin-top" v-if="this.inputForm.des3 ==='1'">
  58. <view class="title">
  59. <text class="red-color ">* </text> 结束月份
  60. </view>
  61. <picker mode="date" :value="inputForm.des2" fields="month" @change="DateChange2">
  62. <view class="picker">
  63. {{inputForm.des2}}
  64. </view>
  65. </picker>
  66. </view>
  67. <view class="cu-form-group margin-top">
  68. <view class="title">
  69. <text class="red-color ">* </text> 金额(万元)
  70. </view>
  71. <input placeholder='请填写金额' type="digit" v-model="inputForm.amount"></input>
  72. </view>
  73. <view class="cu-form-group margin-top">
  74. <view class="title">
  75. <text class="red-color "></text> 备注
  76. </view>
  77. <textarea placeholder='请填写备注' v-model="inputForm.remark"></textarea>
  78. </view>
  79. <view class="cu-form-group margin-top">
  80. <uni-file-picker style="margin-bottom: 10px;" limit="9" ref="picFile" v-model="picLists"
  81. fileMediatype="image" mode="grid" title="图片上传" :auto-upload="autoUpload" @select="select"
  82. @progress="progress" @success="success" @fail="fail" @delete="deleteFile"
  83. :imageStyles="imageStyles">
  84. </uni-file-picker>
  85. </view>
  86. <view class="padding-xl">
  87. <button form-type="submit" class="cu-btn block bg-blue margin-tb-sm lg">提交</button>
  88. </view>
  89. </form>
  90. </view>
  91. </template>
  92. <script>
  93. var graceChecker = require("@/common/graceChecker.js");
  94. import revenueListService from '@/api/revenue/revenueListService'
  95. export default {
  96. onShow() {
  97. this.$auth.checkLogin()
  98. },
  99. data() {
  100. return {
  101. title: '新建企业税收',
  102. inputForm: {
  103. id: '',
  104. qiId: '',
  105. lb: '',
  106. date: [new Date().getFullYear(), new Date().getMonth() + 1],
  107. des1: '',
  108. amount: '',
  109. remark: '',
  110. des2: '',
  111. des3: '',
  112. },
  113. autoUpload: false,
  114. picLists: [],
  115. picUrl: [],
  116. imageStyles: {
  117. width: 90,
  118. height: 90
  119. },
  120. parkList: [],
  121. }
  122. },
  123. created() {
  124. this.getParkList()
  125. },
  126. mounted() {
  127. this.inputForm.des1 = `${this.inputForm.date[0]}-${this.inputForm.date[1]}`;
  128. this.inputForm.des2 = `${this.inputForm.date[0]}-${this.inputForm.date[1]}`;
  129. },
  130. async onLoad(query) {
  131. if (query && query.id) {
  132. this.titile = "修改企业税收";
  133. let {
  134. data
  135. } = await revenueListService.queryById(query.id)
  136. console.log(data)
  137. if (data.pic != null) {
  138. data.pic = data.pic.split(",")
  139. var list = data.pic
  140. list.forEach(item => {
  141. this.picUrl.push({
  142. 'url': item,
  143. 'uuid': item
  144. })
  145. this.picLists.push({
  146. 'url': item,
  147. 'uuid': item
  148. })
  149. })
  150. } else {
  151. data.pic = []
  152. }
  153. this.inputForm = this.recover(this.inputForm, data)
  154. }
  155. },
  156. methods: {
  157. getParkList() {
  158. revenueListService.enterpriseList({
  159. current: 1,
  160. size: -1,
  161. }).then(({
  162. data
  163. }) => {
  164. this.parkList = data.records.map((item) => {
  165. return {
  166. label: item.name,
  167. value: item.id
  168. }
  169. })
  170. console.log(this.parkList, '=============>')
  171. }).catch(e => {
  172. console.log(e)
  173. })
  174. },
  175. DateChange(e) {
  176. this.inputForm.des1 = e.detail.value
  177. },
  178. DateChange2(e) {
  179. this.inputForm.des2 = e.detail.value
  180. },
  181. // 获取上传进度
  182. progress(e) {
  183. console.log('上传进度:', e)
  184. },
  185. // 上传成功
  186. success(e) {
  187. console.log('上传成功')
  188. },
  189. // 上传失败
  190. fail(e) {
  191. console.log('上传失败:', e)
  192. },
  193. deleteFile(e) {
  194. this.picUrl.splice(e.index, 1)
  195. },
  196. // 获取上传状态
  197. select(e) {
  198. console.log('选择文件:', e)
  199. var _this = this
  200. var i = 0
  201. upload()
  202. function upload() {
  203. if (i >= e.tempFiles.length) {
  204. return;
  205. }
  206. var item = e.tempFiles[i]
  207. uni.showLoading({
  208. title: "上传中",
  209. mask: true
  210. });
  211. uni.uploadFile({
  212. url: '/file/upload?uploadPath=', // 仅为示例,非真实的接口地址
  213. filePath: item.url,
  214. name: 'file',
  215. formData: {
  216. 'fileName': item.name
  217. },
  218. header: {
  219. 'token': _this.$auth.getUserToken()
  220. },
  221. success: (res) => {
  222. var data = res.data
  223. if (typeof data['error'] != "undefined") {
  224. uni.showToast({
  225. icon: 'none',
  226. title: '上传失败,请联系开发!'
  227. });
  228. _this.$refs.picFile.clearFiles(_this.picLists.length)
  229. } else {
  230. _this.picUrl.push({
  231. url: data,
  232. uuid: item.uuid
  233. })
  234. i++;
  235. upload()
  236. }
  237. },
  238. fail: () => {
  239. uni.hideLoading();
  240. uni.showToast({
  241. icon: 'none',
  242. title: '上传失败,请联系开发!'
  243. });
  244. _this.$refs.picFile.clearFiles(_this.picLists.length)
  245. },
  246. complete: function() {
  247. uni.hideLoading();
  248. }
  249. });
  250. }
  251. },
  252. formSubmit: function(e) {
  253. //定义表单规则
  254. var rule = [{
  255. name: "qiId",
  256. checkType: "notnull",
  257. checkRule: "",
  258. errorMsg: "企业不能为空"
  259. },
  260. {
  261. name: "lb",
  262. checkType: "notnull",
  263. checkRule: "",
  264. errorMsg: "类别不能为空"
  265. },
  266. {
  267. name: "des1",
  268. checkType: "notnull",
  269. checkRule: "",
  270. errorMsg: "月份不能为空"
  271. },
  272. {
  273. name: "amount",
  274. checkType: "notnull",
  275. checkRule: "",
  276. errorMsg: "金额不能为空"
  277. }
  278. ];
  279. //进行表单检查
  280. var formData = this.inputForm;
  281. var checkRes = graceChecker.check(formData, rule);
  282. if (checkRes) {
  283. uni.showLoading()
  284. this.inputForm.pic = [];
  285. this.picUrl.forEach(item => {
  286. this.inputForm.pic.push(item.url)
  287. })
  288. this.inputForm.pic = this.inputForm.pic.toString();
  289. revenueListService.save(this.inputForm).then(({
  290. data
  291. }) => {
  292. uni.showToast({
  293. title: data,
  294. icon: "success"
  295. });
  296. uni.navigateTo({
  297. url: '/pages/revenue/RevenueList'
  298. })
  299. }).catch((e) => {
  300. })
  301. } else {
  302. uni.showToast({
  303. title: graceChecker.error,
  304. icon: "none"
  305. });
  306. }
  307. }
  308. }
  309. }
  310. </script>
  311. <style>
  312. /* .file-title) {
  313. font-size: 17px !important;
  314. } */
  315. </style>