info6.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <wt-card
  3. title="年度投资情况(单位:万元)"
  4. class="mt-10"
  5. :edit-btn="true"
  6. @edit="change"
  7. @save="save"
  8. >
  9. <el-form class="mt-20" :disabled="disabled">
  10. <div style="width: 1300px; text-align: left" class="mt-20 ml-10">
  11. <span class="title">年份:</span>
  12. <el-select v-model="selectYear" @change="changeYear">
  13. <el-option
  14. v-for="item in years"
  15. :key="item.value"
  16. :label="item.label"
  17. :value="item.value"
  18. />
  19. </el-select>
  20. </div>
  21. <table>
  22. <thead>
  23. <tr>
  24. <th>类型</th>
  25. <th v-for="item in month">
  26. {{ item.month != '合计' ? item.month + '月' : '合计' }}
  27. </th>
  28. <th>合计</th>
  29. </tr>
  30. </thead>
  31. <tbody>
  32. <tr>
  33. <th>计划投资</th>
  34. <th v-for="item in month">
  35. <el-input
  36. class="th-input"
  37. v-model="item.planInvestment"
  38. @input="AddUpdateItem(item)"
  39. >
  40. </el-input>
  41. </th>
  42. <th>{{ allPlanInvestment }}</th>
  43. </tr>
  44. <tr>
  45. <th>累计投资</th>
  46. <th v-for="item in month">
  47. <el-input
  48. class="th-input"
  49. v-model="item.totalInvestment"
  50. @input="AddUpdateItem(item)"
  51. >
  52. </el-input>
  53. </th>
  54. <th>{{ allTotalInvestment }}</th>
  55. </tr>
  56. <tr>
  57. <th>计划纳统投资</th>
  58. <th v-for="item in month">
  59. <el-input
  60. class="th-input"
  61. v-model="item.planNtInvestment"
  62. @input="AddUpdateItem(item)"
  63. >
  64. </el-input>
  65. </th>
  66. <th>{{ allPlanNtInvestment }}</th>
  67. </tr>
  68. <tr>
  69. <th>累计纳统投资</th>
  70. <th v-for="item in month">
  71. <el-input
  72. class="th-input"
  73. v-model="item.totalNtInvestment"
  74. @input="AddUpdateItem(item)"
  75. >
  76. </el-input>
  77. </th>
  78. <th>{{ allTotalNtInvestment }}</th>
  79. </tr>
  80. </tbody>
  81. </table>
  82. </el-form>
  83. </wt-card>
  84. </template>
  85. <script>
  86. import wtCard from '@/components/wt-card/index.vue'
  87. export default {
  88. components: {
  89. wtCard
  90. },
  91. props: {
  92. projectId: {
  93. required: true,
  94. type: String,
  95. default: ''
  96. }
  97. },
  98. watch: {
  99. projectId: {
  100. handler(val) {
  101. this.initYear()
  102. if (val.length > 0) {
  103. this.getList()
  104. }
  105. },
  106. immediate: true
  107. }
  108. },
  109. data() {
  110. return {
  111. allPlanInvestment: 0,
  112. allTotalInvestment: 0,
  113. allPlanNtInvestment: 0,
  114. allTotalNtInvestment: 0,
  115. updateItem: [],
  116. data: [],
  117. month: [
  118. { month: '1-2' },
  119. { month: '3' },
  120. { month: '4' },
  121. { month: '5' },
  122. { month: '6' },
  123. { month: '7' },
  124. { month: '8' },
  125. { month: '9' },
  126. { month: '10' },
  127. { month: '11' },
  128. { month: '12' }
  129. ],
  130. years: [],
  131. years2: [],
  132. selectYear: new Date().getFullYear(),
  133. disabled: true
  134. }
  135. },
  136. methods: {
  137. changeYear(res) {
  138. this.allPlanInvestment = 0
  139. this.allTotalInvestment = 0
  140. this.allPlanNtInvestment = 0
  141. this.allTotalNtInvestment = 0
  142. this.getList()
  143. },
  144. getList() {
  145. this.$api.project
  146. .projectAnnualInvestment({
  147. projectId: this.projectId,
  148. year: this.selectYear
  149. })
  150. .then(res => {
  151. if (res.code === 200) {
  152. this.data = res.data
  153. this.month.map(monthItem => {
  154. const sub = res.data.find(ele => ele.month === monthItem.month)
  155. if (sub) {
  156. monthItem.id = sub.id
  157. monthItem.createDept = sub.createDept
  158. monthItem.createTime = sub.createTime
  159. monthItem.createUser = sub.createUser
  160. monthItem.isDeleted = sub.isDeleted
  161. monthItem.planInvestment = sub.planInvestment
  162. monthItem.planNtInvestment = sub.planNtInvestment
  163. monthItem.projectId = sub.projectId
  164. monthItem.status = sub.status
  165. monthItem.totalInvestment = sub.totalInvestment
  166. monthItem.totalNtInvestment = sub.totalNtInvestment
  167. monthItem.updateTime = sub.updateTime
  168. monthItem.updateUser = sub.updateUser
  169. monthItem.year = sub.year
  170. this.allTotalNtInvestment =
  171. this.allTotalNtInvestment + (sub.totalNtInvestment - 0)
  172. this.allPlanInvestment =
  173. this.allPlanInvestment + (sub.planInvestment - 0)
  174. this.allTotalInvestment =
  175. this.allTotalInvestment + (sub.totalInvestment - 0)
  176. this.allPlanNtInvestment =
  177. this.allPlanNtInvestment + (sub.planNtInvestment - 0)
  178. } else {
  179. monthItem.planInvestment = 0
  180. monthItem.planNtInvestment = 0
  181. monthItem.projectId = this.projectId
  182. monthItem.totalInvestment = 0
  183. monthItem.totalNtInvestment = 0
  184. monthItem.year = this.selectYear
  185. }
  186. })
  187. }
  188. })
  189. },
  190. initYear() {
  191. this.years.length = 0
  192. const year = new Date().getFullYear()
  193. for (let i = 2017; i <= year + 1; i++) {
  194. const item = { label: i, value: i }
  195. this.years.push(item)
  196. }
  197. this.years.reverse()
  198. },
  199. AddUpdateItem(item) {
  200. const sub = this.updateItem.find(ele => ele.month === item.month)
  201. if (sub) {
  202. console.log('这个已经在更新列表中!')
  203. } else {
  204. this.updateItem.push(item)
  205. }
  206. const index = this.data.findIndex(ele => ele.month === item.month)
  207. if (index != -1) {
  208. this.data.splice(this.data.indexOf(index), 1)
  209. }
  210. this.data.push(item)
  211. //重新计算合计
  212. this.allPlanInvestment = 0
  213. this.allTotalInvestment = 0
  214. this.allPlanNtInvestment = 0
  215. this.allTotalNtInvestment = 0
  216. this.data.forEach(ele => {
  217. this.allTotalNtInvestment =
  218. this.allTotalNtInvestment + (ele.totalNtInvestment - 0)
  219. this.allPlanInvestment =
  220. this.allPlanInvestment + (ele.planInvestment - 0)
  221. this.allTotalInvestment =
  222. this.allTotalInvestment + (ele.totalInvestment - 0)
  223. this.allPlanNtInvestment =
  224. this.allPlanNtInvestment + (ele.planNtInvestment - 0)
  225. })
  226. },
  227. change(res) {
  228. this.disabled = res
  229. },
  230. save() {
  231. this.$api.project
  232. .batchSubmitAnnualInvestment(this.updateItem)
  233. .then(res => {
  234. if (res.code === 200) {
  235. this.$message.success(res.msg)
  236. } else {
  237. this.$message.error(res.msg)
  238. }
  239. })
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .title {
  246. width: 60px;
  247. padding-right: 10px;
  248. text-align: center;
  249. }
  250. table {
  251. width: 1280px;
  252. margin: 10px;
  253. margin-top: 20px;
  254. }
  255. thead {
  256. background: #d7d7d7;
  257. }
  258. tr {
  259. height: 40px;
  260. }
  261. th {
  262. height: 40px;
  263. width: 7.69%;
  264. flex: 1;
  265. text-align: center;
  266. border: 1px solid #9c9c9c;
  267. }
  268. .th-input {
  269. height: 100%;
  270. width: 100%;
  271. text-align: center;
  272. border: none;
  273. }
  274. :deep(.el-input__wrapper) {
  275. border: none;
  276. border-radius: revert;
  277. }
  278. :deep(.el-input__inner) {
  279. text-align: center;
  280. }
  281. </style>