BaseEnergyPlanForm.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <a-row>
  6. <a-col :span="24">
  7. <a-form-model-item label="能源计划ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="energyplanid">
  8. <a-input-number v-model="model.energyplanid" placeholder="请输入能源计划ID" style="width: 100%" />
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
  13. <a-input v-model="model.remark" placeholder="请输入备注" ></a-input>
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="24">
  17. <a-form-model-item label="设备ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
  18. <a-input-number v-model="model.equipmentid" placeholder="请输入设备ID" style="width: 100%" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :span="24">
  22. <a-form-model-item label="设备编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentcode">
  23. <a-input v-model="model.equipmentcode" placeholder="请输入设备编号" ></a-input>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :span="24">
  27. <a-form-model-item label="计划日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="plandate">
  28. <j-date placeholder="请选择计划日期" v-model="model.plandate" style="width: 100%" />
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :span="24">
  32. <a-form-model-item label="能源分类ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="energytypeid">
  33. <a-input-number v-model="model.energytypeid" placeholder="请输入能源分类ID" style="width: 100%" />
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :span="24">
  37. <a-form-model-item label="计划值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="planvalue">
  38. <a-input-number v-model="model.planvalue" placeholder="请输入计划值" style="width: 100%" />
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :span="24">
  42. <a-form-model-item label="所属年" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="year">
  43. <a-input-number v-model="model.year" placeholder="请输入所属年" style="width: 100%" />
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :span="24">
  47. <a-form-model-item label="所属月" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="month">
  48. <a-input-number v-model="model.month" placeholder="请输入所属月" style="width: 100%" />
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :span="24">
  52. <a-form-model-item label="日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="day">
  53. <a-input v-model="model.day" placeholder="请输入日期" ></a-input>
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col :span="24">
  57. <a-form-model-item label="所属年月" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yearmonth">
  58. <a-input v-model="model.yearmonth" placeholder="请输入所属年月" ></a-input>
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col :span="24">
  62. <a-form-model-item label="所属周" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="week">
  63. <a-input-number v-model="model.week" placeholder="请输入所属周" style="width: 100%" />
  64. </a-form-model-item>
  65. </a-col>
  66. <a-col :span="24">
  67. <a-form-model-item label="周几" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dayofweek">
  68. <a-input-number v-model="model.dayofweek" placeholder="请输入周几" style="width: 100%" />
  69. </a-form-model-item>
  70. </a-col>
  71. </a-row>
  72. </a-form-model>
  73. </j-form-container>
  74. </a-spin>
  75. </template>
  76. <script>
  77. import { httpAction, getAction } from '@/api/manage'
  78. import { validateDuplicateValue } from '@/utils/util'
  79. export default {
  80. name: 'BaseEnergyPlanForm',
  81. components: {
  82. },
  83. props: {
  84. //表单禁用
  85. disabled: {
  86. type: Boolean,
  87. default: false,
  88. required: false
  89. }
  90. },
  91. data () {
  92. return {
  93. model:{
  94. },
  95. labelCol: {
  96. xs: { span: 24 },
  97. sm: { span: 5 },
  98. },
  99. wrapperCol: {
  100. xs: { span: 24 },
  101. sm: { span: 16 },
  102. },
  103. confirmLoading: false,
  104. validatorRules: {
  105. energyplanid: [
  106. { required: true, message: '请输入能源计划ID!'},
  107. ],
  108. },
  109. url: {
  110. add: "/baseEnergyPlan/baseEnergyPlan/add",
  111. edit: "/baseEnergyPlan/baseEnergyPlan/edit",
  112. queryById: "/baseEnergyPlan/baseEnergyPlan/queryById"
  113. }
  114. }
  115. },
  116. computed: {
  117. formDisabled(){
  118. return this.disabled
  119. },
  120. },
  121. created () {
  122. //备份model原始值
  123. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  124. },
  125. methods: {
  126. add () {
  127. this.edit(this.modelDefault);
  128. },
  129. edit (record) {
  130. this.model = Object.assign({}, record);
  131. this.visible = true;
  132. },
  133. submitForm () {
  134. const that = this;
  135. // 触发表单验证
  136. this.$refs.form.validate(valid => {
  137. if (valid) {
  138. that.confirmLoading = true;
  139. let httpurl = '';
  140. let method = '';
  141. if(!this.model.id){
  142. httpurl+=this.url.add;
  143. method = 'post';
  144. }else{
  145. httpurl+=this.url.edit;
  146. method = 'put';
  147. }
  148. httpAction(httpurl,this.model,method).then((res)=>{
  149. if(res.success){
  150. that.$message.success(res.message);
  151. that.$emit('ok');
  152. }else{
  153. that.$message.warning(res.message);
  154. }
  155. }).finally(() => {
  156. that.confirmLoading = false;
  157. })
  158. }
  159. })
  160. },
  161. }
  162. }
  163. </script>