params3.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <div class='flex flex-justify-start flex-align-center flex-col'>
  3. <div class='flex flex-center full-width flex-justify-between mt-10 mb-10'>
  4. <span class='full-width text-left bold'>{{ info.dictValue }}</span>
  5. <el-button v-if='detail.can_update' type='primary' @click='update'>
  6. {{ disabled ? '编 辑' : '保 存' }}
  7. </el-button>
  8. </div>
  9. <div class="mt-10 mb-10 full-width" style="width: 93%;">
  10. <base-button v-if='detail.can_update' title="新增年度" icon="Plus" @click='addYear(1)'/>
  11. </div>
  12. <div class='mt-10' style='width: 90%;'>
  13. <el-form
  14. :model="form"
  15. label-width='180px'
  16. :disabled='disabled'
  17. label-position="left"
  18. class='form-content flex flex-col'
  19. >
  20. <el-form-item v-for='(item,index) in completeCount' :key='item' label-width='0'>
  21. <div class='flex flex-col flex-center full-width'>
  22. <div class='flex flex-center flex-justify-between full-width'>
  23. <div class='flex-child-average full-width flex flex-center'>
  24. <span style='width: 320px'>{{
  25. form.month_plan_complete_amount[index] ? form.month_plan_complete_amount[index].year : ''
  26. }}年度计划投资(万元)</span>
  27. <div class='disable-input' @change='change(item)'>
  28. {{ form.month_plan_complete_amount[index] ? form.month_plan_complete_amount[index].sum : '2' }}
  29. </div>
  30. </div>
  31. <div style='width: 20px'></div>
  32. <div class='flex-child-average full-width flex flex-center'>
  33. <span style='width: 380px'>{{
  34. form.month_plan_complete_amount[index] ? form.month_plan_complete_amount[index].year : ''
  35. }}年度累计投资(万元)</span>
  36. <div class='disable-input' @change='change(item)'>
  37. {{ form.month_complete_amount[index] ? form.month_complete_amount[index].sum : '2' }}
  38. </div>
  39. <div class='btnSub pointer' @click='showMonth(form.month_complete_amount[index].year ,1,index)'>月填报
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </el-form-item>
  45. </el-form>
  46. </div>
  47. <div class="mt-20 mb-10 full-width" style="width: 93%;">
  48. <base-button v-if='detail.can_update' title="新增年度" icon="Plus" @click='addYear(2)'/>
  49. </div>
  50. <div class='mt-10' style='width: 90%;'>
  51. <el-form
  52. :model="form"
  53. label-width='180px'
  54. :disabled='disabled'
  55. label-position="left"
  56. class='form-content flex flex-col'
  57. >
  58. <el-form-item v-for='(item,index) in investmentCount' :key='item' label-width='0'>
  59. <div class='flex flex-col flex-center full-width'>
  60. <div class='flex flex-center flex-justify-between full-width'>
  61. <div class='flex-child-average full-width flex flex-center'>
  62. <span style='width: 400px'>{{ form.month_plan_investment[index].year }}年度计划纳统投资(万元)</span>
  63. <el-input v-model='form.month_plan_investment[index].sum' @change='change(item)'></el-input>
  64. </div>
  65. <div style='width: 20px'></div>
  66. <div class='flex-child-average full-width flex flex-center'>
  67. <span style='width: 440px'>{{ form.month_plan_investment[index].year }}年度累计纳统投资(万元)</span>
  68. <div class='disable-input' @change='change(item)'>{{ form.month_investment_amount.sum }}</div>
  69. <div class='btnSub pointer' @click='showMonth(form.month_plan_investment[index].year,2,index)'>月填报
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </el-form-item>
  75. </el-form>
  76. </div>
  77. <el-dialog v-model='show' :title='current ? current.year + "年度" : ""' width='1260px'
  78. @close='update(false)'>
  79. <div class='flex flex-center flex-align-start'>
  80. <div>
  81. <div class='padding-top'></div>
  82. <div class='padding-top mt-20 mr-10 bold'>计划投资:</div>
  83. <div class='padding-top mt-10 mr-10 bold'>累计投资:</div>
  84. </div>
  85. <div>
  86. <div class='mr-5 flex flex-center '>
  87. <div v-for='(item,index) in 11' :key='item' class='title'>
  88. <div v-if='index === 0'>
  89. 1-2月
  90. </div>
  91. <div v-else>
  92. {{item + 1}}月
  93. </div>
  94. </div>
  95. </div>
  96. <div class='mr-5 flex flex-center'>
  97. <div v-for='(item,index) in current.planMonths' :key='item'>
  98. <input class='input' v-model="item.data" @change='changeMonth(item,1,index)'/>
  99. </div>
  100. </div>
  101. <div class='mr-5 flex flex-center'>
  102. <div v-for='(item,index) in current.months' :key='item.name'>
  103. <input class='input' v-model="item.data" @change='changeMonth(item,2,index)'>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div class='mt-20 full-width flex text-left red'>* 请按月份进行填报,单位:万元</div>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import baseButton from '@/components/base-button.vue'
  114. export default {
  115. name: 'params3',
  116. components: { baseButton },
  117. props: {
  118. info: {
  119. type: Object,
  120. default: null
  121. },
  122. detail: {
  123. type: Object,
  124. default: null
  125. }
  126. },
  127. watch: {
  128. detail: {
  129. handler (val) {
  130. if (Object.keys(val).length > 1) {
  131. this.init(val)
  132. }
  133. },
  134. immediate: true
  135. }
  136. },
  137. data () {
  138. return {
  139. show: false,
  140. disabled: true,
  141. investmentCount: 0,
  142. completeCount: 0,
  143. list1: [],
  144. list2: [],
  145. form: {},
  146. current: null
  147. }
  148. },
  149. methods: {
  150. /**
  151. *
  152. * @param type 1计划投资 2 纳统投资
  153. */
  154. addYear (type) {
  155. this.disabled = false
  156. if (type === 1) {
  157. this.form.month_complete_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_complete_amount[0].year)))
  158. this.form.month_plan_complete_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_plan_complete_amount[0].year)))
  159. this.completeCount = this.completeCount + 1
  160. } else if (type === 2) {
  161. this.form.month_investment_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_investment_amount[0].year)))
  162. this.form.month_plan_investment.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_plan_investment[0].year)))
  163. this.investmentCount = this.investmentCount + 1
  164. }
  165. },
  166. nextYear (year) {
  167. const tmp2 = {}
  168. tmp2.year = (year + 1).toString()
  169. tmp2.sum = ''
  170. tmp2.monthlyData = []
  171. for (let i = 1; i <= 12; i++) {
  172. const item2 = { year: tmp2.year, data: '', month: i.toString() }
  173. tmp2.monthlyData.push(item2)
  174. }
  175. return tmp2
  176. },
  177. init (res) {
  178. this.investmentCount = Math.max(res.month_plan_investment.length, res.month_investment_amount.length)
  179. // 求出差集
  180. const dd = res.month_plan_investment.filter((sub) => {
  181. return res.month_investment_amount.findIndex(ele => sub.year !== ele.year) !== -1
  182. }).map(sub => { // data -》 ''
  183. sub.monthlyData.map(ele => {
  184. ele.data = ele.data ? ele.data : ''
  185. return ele
  186. })
  187. return sub
  188. })
  189. // 复制差集
  190. if (res.month_plan_investment.length === this.completeCount) {
  191. dd.forEach(sub => {
  192. res.month_investment_amount.push(sub)
  193. })
  194. } else {
  195. dd.forEach(sub => {
  196. res.month_plan_investment.push(sub)
  197. })
  198. }
  199. this.completeCount = Math.max(res.month_complete_amount.length, res.month_plan_complete_amount.length)
  200. // 求出差集
  201. const d = res.month_complete_amount.filter((sub) => {
  202. return res.month_plan_complete_amount.findIndex(ele => sub.year !== ele.year) !== -1
  203. }).map(sub => { // data -》 ''
  204. sub.monthlyData.map(ele => {
  205. ele.data = ele.data ? ele.data : ''
  206. return ele
  207. })
  208. return sub
  209. })
  210. // 复制差集
  211. if (res.month_complete_amount.length === this.completeCount) {
  212. d.forEach(sub => {
  213. if (res.month_plan_complete_amount.findIndex(ele => ele.year === sub.year) === -1) {
  214. res.month_plan_complete_amount.push(sub)
  215. }
  216. })
  217. } else {
  218. d.forEach(sub => {
  219. if (res.month_complete_amount.findIndex(ele => ele.year === sub.year) === -1) {
  220. res.month_complete_amount.push(sub)
  221. }
  222. })
  223. }
  224. this.form = res
  225. },
  226. change (item) {
  227. this.form[item.code] = item.value
  228. this.form[item.code2] = item.value2
  229. },
  230. update (show = Boolean) {
  231. this.disabled = !this.disabled
  232. this.form.projectId = this.form.id
  233. delete this.form._id
  234. this.$api.project.proUpdate(this.detail).then(res => {
  235. if (res.code === 200) {
  236. if (show) {
  237. this.$message.success(res.msg)
  238. }
  239. } else {
  240. this.$message.error(res.msg)
  241. }
  242. })
  243. },
  244. /**
  245. *
  246. * @param year
  247. * @param type 1 年度投资 2 纳统投资
  248. * @param index 索引
  249. */
  250. showMonth (year, type, index) {
  251. this.$nextTick(() => {
  252. const item = { editType: type, year, index }
  253. if (type === 1) {
  254. item.planMonths = this.form.month_plan_complete_amount.find(sub => sub.year === year).monthlyData
  255. item.months = this.form.month_complete_amount.find(sub => sub.year === year).monthlyData
  256. } else if (type === 2) {
  257. item.planMonths = this.form.month_plan_investment.find(sub => sub.year === year).monthlyData
  258. item.months = this.form.month_investment_amount.find(sub => sub.year === year).monthlyData
  259. }
  260. this.current = Object.assign({}, item)
  261. for (let i = 1; i <= 11; i++) {
  262. const index = this.current.months.findIndex(sub => sub.month === i.toString())
  263. if (index === -1 && this.current.months.length < 11) {
  264. const ele = { month: i.toString(), data: '', year: '' }
  265. this.current.months.push(ele)
  266. }
  267. const planIndex = this.current.planMonths.findIndex(sub => sub.month === i.toString())
  268. if (planIndex === -1 && this.current.planMonths.length < 11) {
  269. const sub = { month: i.toString(), data: '', year: '' }
  270. this.current.planMonths.push(sub)
  271. }
  272. }
  273. })
  274. this.show = !this.show
  275. },
  276. /**
  277. *
  278. * @param res
  279. * @param type 1 计划 2 累计
  280. * current 1 年度投资 2 纳统投资
  281. */
  282. changeMonth (res, type, index) {
  283. setTimeout(() => {
  284. console.log(res)
  285. if (this.current.editType === 1) {
  286. if (type === 1) {
  287. this.form.month_plan_complete_amount[this.current.index].monthlyData[index] = res
  288. } else {
  289. this.form.month_complete_amount[this.current.index].monthlyData[index] = res
  290. }
  291. } else if (this.current.editType === 2) {
  292. console.log(this.current)
  293. if (type === 1) {
  294. this.form.month_plan_investment[this.current.index].monthlyData[index] = res
  295. } else {
  296. this.form.month_investment_amount[this.current.index].monthlyData[index] = res
  297. }
  298. }
  299. console.log(this.form.month_plan_complete_amount)
  300. }, 1000)
  301. },
  302. getSum (list) {
  303. let sum = 0
  304. list.forEach(sub => {
  305. if (sub.data.length > 0) {
  306. sum = sum + Number.parseInt(sub.data)
  307. }
  308. })
  309. return sum
  310. }
  311. }
  312. }
  313. </script>
  314. <style lang='scss' scoped>
  315. .form-content {
  316. border: 1px solid #eeeeee;
  317. padding: 20px;
  318. :deep(.el-input.is-disabled .el-input__inner) {
  319. color: #343434;
  320. }
  321. :deep(.el-textarea.is-disabled .el-textarea__inner) {
  322. color: #343434;
  323. }
  324. }
  325. .grid {
  326. display: grid;
  327. grid-template-columns: auto auto;
  328. grid-column-gap: 20px;
  329. }
  330. .title {
  331. width: 70px;
  332. padding: 0 11px;
  333. margin-bottom: 10px;
  334. font-weight: bold;
  335. }
  336. .input {
  337. width: 70px;
  338. height: 30px;
  339. border: #e7e7e7 solid 1px;
  340. padding: 0 10px;
  341. border-right: none;
  342. }
  343. .input:last-child {
  344. width: 70px;
  345. height: 40px;
  346. padding: 0 10px;
  347. border-right: #e7e7e7 solid 1px;
  348. }
  349. .disable-input {
  350. height: 30px;
  351. width: 100%;
  352. border-radius: 4px;
  353. background-color: #F5F7FA;
  354. border: #E6E8ED solid 1px;
  355. text-align: left;
  356. padding: 0 10px;
  357. color: #343434;
  358. }
  359. .btnSub {
  360. color: white;
  361. width: 120px;
  362. margin-left: 10px;
  363. height: 30px;
  364. background-color: #EDAC56;
  365. border-radius: 30px;
  366. padding: 0 10px;
  367. }
  368. </style>