index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="container">
  3. <page-title>年度计划录入</page-title>
  4. <view class="cards-list">
  5. <view class="card only-card">
  6. <!-- 项目名称 -->
  7. <view class="card-item first-card-item">
  8. <view class="card-item-name">项目名称</view>
  9. <view class="card-item-input">{{BindName || "--"}}</view>
  10. </view>
  11. <!-- 年度 -->
  12. <view class="card-item" @click="yearShowChoose()">
  13. <view class="card-item-name">年度</view>
  14. <view class="card-item-description">
  15. <view v-if="Bindyear">{{Bindyear || "--"}}</view>
  16. <view v-else class="remind-text">请选择年度</view>
  17. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  18. </view>
  19. </view>
  20. <!-- 月份标题 -->
  21. <view class="card-name" style="margin-top: 36rpx;">
  22. <view class="card-name-title">
  23. <text class="card-name-description">月份</text>
  24. </view>
  25. <view class="card-name-title">
  26. <text class="card-name-description">资金(万元)</text>
  27. </view>
  28. </view>
  29. <!-- 月份值 -->
  30. <view class="card-item" v-for="(item,index) in pageForm" :key="index">
  31. <view class="card-item-name">{{item.ymonth}}月</view>
  32. <input v-model="item.amt" type="number" class="card-item-input" placeholder="请填写金额"
  33. placeholder-style="color: #D8D8D8" maxlength="20" :disabled="banSubmit" />
  34. </view>
  35. </view>
  36. <view class="confirm-btn" :class="banSubmit?'ban-submit':''" @click="confirmParams()">保存</view>
  37. </view>
  38. <!-- 年度选择 -->
  39. <u-picker :show="yearShow" :defaultIndex="defaultIndex" :columns="yearColumns" @confirm="yearClose"
  40. @cancel="yearClose" @close="yearClose" closeOnClickOverlay></u-picker>
  41. </view>
  42. </template>
  43. <script setup>
  44. import config from '@/config.js'
  45. import {
  46. ref
  47. } from 'vue'
  48. import {
  49. onLoad
  50. } from "@dcloudio/uni-app"
  51. import {
  52. getYearlyById,
  53. saveYearly
  54. } from "@/api/work/weeklyAndMonthly.js"
  55. let Bindyear = ref(null);
  56. let BindName = ref(null);
  57. let BindSubId = ref(null);
  58. // =============================年度选择
  59. let defaultIndex = ref(0)
  60. let yearShow = ref(false);
  61. let yearColumns = ref([
  62. ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013",
  63. "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
  64. "2027", "2028", "2029", "2030", "2031", "2032", "2033"
  65. ]
  66. ])
  67. function yearShowChoose() {
  68. yearShow.value = true;
  69. }
  70. function yearClose(e) {
  71. if (e) {
  72. Bindyear.value = e.value[0];
  73. getYearlyDetail({
  74. subId: BindSubId.value,
  75. year: e.value[0]
  76. })
  77. banSubmit.value = false;
  78. }
  79. yearShow.value = false
  80. }
  81. let pageForm = ref([{
  82. name: "01",
  83. amt: null
  84. },
  85. {
  86. name: "02",
  87. amt: null
  88. },
  89. {
  90. name: "03",
  91. amt: null
  92. },
  93. {
  94. name: "04",
  95. amt: null
  96. },
  97. {
  98. name: "05",
  99. amt: null
  100. },
  101. {
  102. name: "06",
  103. amt: null
  104. },
  105. {
  106. name: "07",
  107. amt: null
  108. },
  109. {
  110. name: "08",
  111. amt: null
  112. },
  113. {
  114. name: "09",
  115. amt: null
  116. },
  117. {
  118. name: "10",
  119. amt: null
  120. },
  121. {
  122. name: "11",
  123. amt: null
  124. },
  125. {
  126. name: "12",
  127. amt: null
  128. },
  129. ])
  130. // 获取数据
  131. function getYearlyDetail(sendParams) {
  132. let params = {
  133. subId: sendParams.subId,
  134. year: sendParams.year
  135. }
  136. getYearlyById(params).then(res => {
  137. pageForm.value = res.data.list
  138. })
  139. }
  140. let banSubmit = ref(false);
  141. let isSubmit = ref(false);
  142. // 确认数据
  143. function confirmParams() {
  144. if (banSubmit.value || isSubmit.value) return;
  145. uni.showModal({
  146. title: "保存确认",
  147. content: "确定要保存该年度计划录入吗?",
  148. success: function(res) {
  149. if (res.confirm) {
  150. let params = {
  151. subId: BindSubId.value,
  152. amtPlans: pageForm.value
  153. }
  154. let paramsFormat = JSON.parse(JSON.stringify(params))
  155. paramsFormat.amtPlans.forEach(item => {
  156. item.ymonth = `${Bindyear.value}${item.ymonth}`
  157. })
  158. isSubmit.value = true;
  159. saveYearly(paramsFormat).then(res => {
  160. if (res.code === 200) {
  161. isSubmit.value = false;
  162. banSubmit.value = true;
  163. uni.showToast({
  164. title: "保存成功",
  165. icon: "success",
  166. duration: 2000
  167. })
  168. }
  169. }).catch(() => {
  170. isSubmit.value = false;
  171. uni.showToast({
  172. title: "保存失败",
  173. icon: "error",
  174. duration: 2000
  175. })
  176. })
  177. } else if (res.cancel) {
  178. uni.showToast({
  179. title: "取消保存",
  180. icon: "none",
  181. duration: 2000,
  182. })
  183. }
  184. },
  185. })
  186. }
  187. onLoad((options) => {
  188. Bindyear.value = options.year;
  189. defaultIndex.value = [Number(Bindyear.value) - 2000]
  190. BindName.value = options.title;
  191. BindSubId.value = options.subId;
  192. getYearlyDetail(options)
  193. })
  194. </script>
  195. <style lang="scss" scoped>
  196. </style>