0b282a8d5e140483fc536842d04f20abfce44911.svn-base 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div v-if="visible">
  3. <el-dialog id="reviseplanDialog" :title="title" :destroy-on-close="true" :visible.sync="visible" :close-on-click-modal="false" append-to-body :before-close="closeDialog" width="90%">
  4. <el-row class="dialogMinHeight">
  5. <el-button class="successBorder" size="medium" style="position: absolute;z-index: 1;right: 2px;top: 2px;" @click="saveData()">应用</el-button>
  6. <el-tabs v-model="parentActiveName" type="border-card" @tab-click="handleClick">
  7. <el-tab-pane label="栏舍配方" name="栏舍配方">
  8. <DhedFormula ref="DhedFormula" :parent-date="date" />
  9. </el-tab-pane>
  10. <el-tab-pane label="撒料计划" name="撒料计划">
  11. <MaterialIssuancePlan ref="MaterialIssuancePlan" :parent-date="date" />
  12. </el-tab-pane>
  13. <el-tab-pane label="预混计划" name="预混计划">
  14. <PremixedPlan ref="PremixedPlan" :parent-date="date" />
  15. </el-tab-pane>
  16. </el-tabs>
  17. </el-row>
  18. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  19. <el-button class="cancelClose" @click="closeDialog()">关闭</el-button>
  20. </div>
  21. </el-dialog>
  22. </div>
  23. </template>
  24. <script>
  25. import { PostDataByName } from '@/api/common'
  26. import DhedFormula from './typePage/dhedFormula.vue'
  27. import MaterialIssuancePlan from './typePage/materialIssuancePlan.vue'
  28. import PremixedPlan from './typePage/premixedPlan.vue'
  29. import { MessageBox } from 'element-ui'
  30. import Cookies from 'js-cookie'
  31. export default {
  32. name: 'RevisePlan',
  33. components: {
  34. DhedFormula, MaterialIssuancePlan, PremixedPlan
  35. },
  36. props: {
  37. show: { type: Boolean, default: false }, // 弹框可见标志
  38. parentActiveName: { type: String, defalut: '栏舍配方' },
  39. parentDate: { type: String, defalut: '' }
  40. },
  41. data() {
  42. return {
  43. typeList: [{ id: '1', effect: 'dark', label: '栏舍配方' }, { id: '2', effect: 'plain', label: '撒料计划' }, { id: '3', effect: 'plain', label: '预混计划' }],
  44. visible: this.show,
  45. dialogFormVisible: false,
  46. dialogStatus: '',
  47. rules: {},
  48. date: '',
  49. parentActiveName: '',
  50. temp: {},
  51. title: '',
  52. isDhedFormula: true,
  53. isMaterialIssuancePlan: false,
  54. isPremixedPlan: false,
  55. textMap: {
  56. revisePlan: '修改计划'
  57. },
  58. isokDisable: false,
  59. requestParam: {}
  60. }
  61. },
  62. watch: {
  63. // 监听show,visible 随着show变化而变化
  64. show: {
  65. immediate: true,
  66. handler(show) {
  67. this.visible = show
  68. }
  69. },
  70. parentDate: {
  71. immediate: true,
  72. handler(newVal, oldVal) {
  73. console.log('newVal-date', newVal)
  74. this.date = newVal
  75. this.title = '修改计划——' + this.date
  76. }
  77. },
  78. parentActiveName: {
  79. immediate: true,
  80. handler(newVal, oldVal) {
  81. console.log('newVal===', newVal)
  82. console.log('oldVal', oldVal)
  83. this.parentActiveName = newVal
  84. }
  85. }
  86. },
  87. created() {
  88. },
  89. methods: {
  90. closeDialog() {
  91. this.$emit('update:show', false) // 子组件更新弹框隐藏
  92. this.$emit('activeName', '栏舍配方')
  93. },
  94. saveData() {
  95. console.log('点击了应用')
  96. MessageBox.confirm('是否确认将当前修改计划应用至' + this.date, {
  97. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  98. }).then(() => {
  99. this.requestParam.name = 'updatedownloadedplanDone'
  100. this.requestParam.parammaps = {}
  101. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  102. this.requestParam.parammaps.date = this.date
  103. PostDataByName(this.requestParam).then(response => {
  104. if (response.msg === 'fail') {
  105. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  106. } else {
  107. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  108. this.closeDialog()
  109. this.$parent.getList()
  110. }
  111. })
  112. }).catch(() => {
  113. this.$message({ type: 'info', message: '已取消应用' })
  114. })
  115. },
  116. handleClick(item) {
  117. console.log(item.name)
  118. if (item.name == '撒料计划') {
  119. this.$refs.MaterialIssuancePlan.getIsDisplay()
  120. this.$refs.MaterialIssuancePlan.getDownList()
  121. } else if (item.name == '栏舍配方') {
  122. this.$refs.DhedFormula.getIsDisplay()
  123. this.$refs.DhedFormula.getDownList()
  124. } else {
  125. this.$refs.PremixedPlan.getDownList()
  126. this.$refs.PremixedPlan.getIsDisplay()
  127. this.$refs.PremixedPlan.getList()
  128. }
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. #reviseplanDialog {
  135. margin-top: -10vh !important
  136. }
  137. </style>