waterPriceSetting.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <el-dialog
  3. title="请选择需设置的年度"
  4. :visible.sync="dialogVisible"
  5. :close-on-click-modal="false"
  6. :close-on-press-escape="false"
  7. @close="handleClose"
  8. width="640px"
  9. >
  10. <el-form
  11. ref="baseForm"
  12. class="base-form"
  13. label-position="right"
  14. label-width="95px"
  15. :model="baseForm"
  16. :rules="rules"
  17. size="small"
  18. >
  19. <el-row>
  20. <el-col :span="24">
  21. <el-row>
  22. <el-col :span="24" style="text-align:left">
  23. <el-form-item label="年度" prop="dateTime">
  24. <el-row>
  25. <el-col>
  26. <el-select
  27. placeholder="请选择年度"
  28. style="width:100%"
  29. v-model="baseForm.dateTime">
  30. <el-option
  31. v-for="item in options"
  32. :key="item.value"
  33. :label="item.label"
  34. :value="item.value"
  35. >
  36. </el-option>
  37. </el-select>
  38. </el-col>
  39. </el-row>
  40. </el-form-item>
  41. </el-col>
  42. </el-row>
  43. </el-col>
  44. <el-col :span="24">
  45. <el-row :gutter="5">
  46. <el-col :span="18">
  47. <el-checkbox v-model="checked">
  48. <b>沿用上一年 </b>
  49. <p class="label_text">(沿用上一年的情况下,所有区域都创建一个和上年同样的水权设置信息可修改;<br>不选沿用的情况下,所有区域重新为0,重新设置)</p>
  50. </el-checkbox>
  51. </el-col>
  52. </el-row>
  53. </el-col>
  54. </el-row>
  55. </el-form>
  56. <div style="text-align: right;margin-top:30px;">
  57. <el-button type="info" plain @click="resetForm('baseForm')"
  58. >取消</el-button
  59. >
  60. <el-button
  61. type="primary"
  62. style="margin-left:16px;"
  63. @click="submitForm('baseForm')"
  64. :disabled="dialogSubmitLoading"
  65. :loading="dialogSubmitLoading"
  66. >确定</el-button
  67. >
  68. </div>
  69. </el-dialog>
  70. </template>
  71. <script>
  72. import { addWaterright } from '@/api/waterright/index.js'
  73. import { assign } from 'lodash-es';
  74. export default {
  75. name:'waterPriceSetting',
  76. props: {
  77. visible: {
  78. type: Boolean,
  79. default: false
  80. }
  81. },
  82. data() {
  83. return {
  84. dialogSubmitLoading: false,
  85. dialogVisible: false,
  86. baseForm: {
  87. dateTime: ''
  88. },
  89. hasFetched: false,
  90. options:[],
  91. checked: false,
  92. rules: {
  93. dateTime: [
  94. { required: true, message: '请选择您的年份', trigger: 'blur' }
  95. ]
  96. }
  97. };
  98. },
  99. watch: {
  100. visible(val) {
  101. if (val !== this.dialogVisible) {
  102. this.dialogVisible = val;
  103. }
  104. },
  105. },
  106. mounted() {
  107. this.setYear()
  108. },
  109. methods: {
  110. setYear() {
  111. this.options = []
  112. let date = new Date
  113. let currentYear = date.getFullYear()
  114. this.currentYear = currentYear
  115. for (let i = 0; i < 5; i++) {
  116. this.options.push({
  117. label: currentYear + i,
  118. value: currentYear + i
  119. })
  120. }
  121. },
  122. async addWaterrightHandler() {
  123. const useOldStatus = this.checked ? 1 : 0
  124. const waterrightYear = this.baseForm.dateTime
  125. await addWaterright({
  126. useOldStatus,
  127. waterrightYear
  128. })
  129. this.handleClose()
  130. this.$emit('refresh')
  131. },
  132. resetForm(formName) {
  133. this.$refs[formName].resetFields();
  134. this.dialogVisible = false;
  135. },
  136. submitForm(formName) {
  137. this.$refs[formName].validate((valid) => {
  138. valid && this.addWaterrightHandler()
  139. })
  140. },
  141. handleClose() {
  142. this.$emit('update:visible', false);
  143. this.resetForm('baseForm');
  144. },
  145. }
  146. };
  147. </script>
  148. <style lang="scss" scoped>
  149. ::v-deep .base-form{
  150. padding: 0;
  151. }
  152. ::v-deep .el-checkbox{
  153. margin-top: 10px;
  154. }
  155. ::v-deep .el-checkbox__input{
  156. margin-top: -75px;
  157. }
  158. ::v-deep .el-checkbox__input.is-checked+.el-checkbox__label{
  159. p{
  160. color:#14A478;
  161. }
  162. }
  163. .label_text{
  164. width:550px;
  165. padding:0;
  166. margin:0;
  167. color: #999;
  168. font-size: 14px;
  169. }
  170. .input-number {
  171. width: 100%;
  172. }
  173. .base-form {
  174. max-height: 70vh;
  175. overflow-y: auto;
  176. overflow-x: hidden;
  177. padding: 0 20px;
  178. }
  179. </style>
  180. <style lang="css" scoped>
  181. ::v-deep .el-dialog__header {
  182. border-bottom: 1px solid #ebeef5;
  183. }
  184. </style>