a2a0fb7143d7866e11faf1445e2429f629ffbdba.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div v-if="visible">
  3. <!-- 干物质调节-配方选择 -->
  4. <el-dialog title="干物质调节-配方选择" :destroy-on-close="true" :visible.sync="visible" :close-on-click-modal="false" append-to-body :before-close="closeDialog" width="35%">
  5. <div style="min-height:200px;justify-content:center;align-items:center;display:flex;">
  6. <div style="height: 40px;width: 80%;">
  7. <span style="margin-right: 10px;">请选择栏舍配方:</span>
  8. <el-select v-model="temp.ftid" filterable class="filter-item">
  9. <el-option v-for="item in balconicFormulaList" :key="item.id" :label="item.name" :value="item.id" />
  10. </el-select>
  11. </div>
  12. </div>
  13. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  14. <el-button class="minCancel" @click="closeDialog()">取消</el-button>
  15. <el-button class="miniSuccess" @click="handleNextSamplingSelection()">下一步</el-button>
  16. </div>
  17. </el-dialog>
  18. <!-- 干物质调节—采样选择 -->
  19. <el-dialog :title="textMap[samplingSelection.dialogStatus]" :visible.sync="samplingSelection.dialogFormVisible" append-to-body :close-on-click-modal="false" width="80%">
  20. <div class="dialogMinHeight">
  21. <div class="search filter-item">
  22. <el-date-picker v-model="samplingSelection.getdataListParm.parammaps.date" type="date" placeholder="请选择时间" :clearable="false" style="width: 230px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" />
  23. <el-select v-model="samplingSelection.getdataListParm.parammaps.enable" filterable placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  24. <el-option v-for="item in samplingSelection.shedNameList" :key="item.id" :label="item.name" :value="item.id" />
  25. </el-select>
  26. <el-select v-model="samplingSelection.getdataListParm.parammaps.enable" filterable placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  27. <el-option v-for="item in samplingSelection.frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  28. </el-select>
  29. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  30. </div>
  31. <div class="table" style="margin-top: 10px;">
  32. <el-table
  33. :key="samplingSelection.tableKey"
  34. v-loading="samplingSelection.listLoading"
  35. element-loading-text="给我一点时间"
  36. :data="samplingSelection.list"
  37. border
  38. fit
  39. highlight-current-row
  40. style="width: 100%;"
  41. :row-style="rowStyle"
  42. :cell-style="cellStyle"
  43. class="elTable table-fixed"
  44. @selection-change="handleSelectionChange"
  45. >
  46. <el-table-column type="selection" align="center" width="50" />
  47. <el-table-column label="序号" align="center" type="index" width="50px" />
  48. <el-table-column label="栏舍名称" prop="drivercode" min-width="110px" align="center" />
  49. <el-table-column label="班次" prop="drivercode" min-width="110px" align="center" />
  50. <el-table-column label="鲜样重量(g)" prop="drivercode" min-width="110px" align="center" />
  51. <el-table-column label="烘干重量(g)" prop="drivercode" min-width="110px" align="center" />
  52. <el-table-column label="理论干物质" prop="drivercode" min-width="110px" align="center" />
  53. <el-table-column label="实际干物质" prop="drivercode" min-width="110px" align="center" />
  54. <el-table-column label="操作人" prop="drivercode" min-width="110px" align="center" />
  55. <el-table-column label="操作日期" prop="drivercode" min-width="110px" align="center" />
  56. </el-table>
  57. </div>
  58. </div>
  59. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  60. <el-button class="minCancel" @click="closeDialog()">取消</el-button>
  61. <el-button class="miniSuccess" @click="handleNextChangeDetails()">下一步</el-button>
  62. </div>
  63. </el-dialog>
  64. <!-- 干物质调节-变化详情 -->
  65. <el-dialog :title="textMap[changeDetails.dialogStatus]" :visible.sync="changeDetails.dialogFormVisible" append-to-body :close-on-click-modal="false" width="80%">
  66. <div class="dialogMinHeight">
  67. <div class="table">
  68. <el-table
  69. :key="changeDetails.tableKey"
  70. v-loading="changeDetails.listLoading"
  71. element-loading-text="给我一点时间"
  72. :data="changeDetails.list"
  73. border
  74. fit
  75. highlight-current-row
  76. style="width: 100%;"
  77. :row-style="rowStyle"
  78. :cell-style="cellStyle"
  79. class="elTable table-fixed"
  80. :span-method="objectSpanMethod"
  81. >
  82. <el-table-column label="栏舍" prop="barname" min-width="90px" align="center" class-name="small-padding fixed-width" fixed="left" />
  83. <el-table-column label="班次" prop="times" min-width="90px" align="center" class-name="small-padding fixed-width" fixed="left" />
  84. <el-table-column label="调节前班次重量" prop="softccount" min-width="70px" align="center" />
  85. <el-table-column label="调节后班次重量" prop="softccount" min-width="70px" align="center" />
  86. <el-table-column label="调节前饲喂干物质量" prop="softccount" min-width="70px" align="center" />
  87. <el-table-column label="调节后饲喂干物质量" prop="softccount" min-width="70px" align="center" />
  88. <el-table-column label="调节前采样干物质量" prop="softccount" min-width="70px" align="center" />
  89. <el-table-column label="调节后采样干物质量" prop="softccount" min-width="70px" align="center" />
  90. <el-table-column label="调节前日投喂量" prop="softccount" min-width="70px" align="center" />
  91. <el-table-column label="调节后日投喂量" prop="softccount" min-width="70px" align="center" />
  92. </el-table>
  93. </div>
  94. </div>
  95. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  96. <el-button class="minCancel" @click="closeDialog()">取消</el-button>
  97. <el-button class="miniSuccess" @click="handleNextLast()">下一步</el-button>
  98. </div>
  99. </el-dialog>
  100. </div>
  101. </template>
  102. <script>
  103. import { GetDataByName, PostDataByName } from '@/api/common'
  104. import { handleTableSpan, handleObjectSpanMethod } from '@/utils/index.js'
  105. import Cookies from 'js-cookie'
  106. import { MessageBox } from 'element-ui'
  107. export default {
  108. name: 'RevisePlan',
  109. components: {},
  110. props: {
  111. show: { type: Boolean, default: false }
  112. },
  113. data() {
  114. return {
  115. visible: this.show,
  116. dialogFormVisible: false,
  117. dialogStatus: '',
  118. balconicFormulaList: [{ id: 1, name: '泌乳牛高产 V1' }, { id: 2, name: '泌乳牛高产 V2' }, { id: 3, name: '泌乳牛高产 V3' }],
  119. temp: {
  120. ftid: ''
  121. },
  122. samplingSelection: {
  123. dialogFormVisible: false,
  124. dialogStatus: '',
  125. shedNameList: [{ id: 1, name: '栏舍名称1' }, { id: 2, name: '栏舍名称2' }, { id: 3, name: '栏舍名称3' }],
  126. frequencyList: [{ id: 1, name: '第一班' }, { id: 2, name: '第二班' }, { id: 3, name: '第三班' }, { id: 4, name: '第四班' }],
  127. getdataListParm: {
  128. name: 'getDriverList',
  129. page: 1,
  130. offset: 1,
  131. pagecount: 0,
  132. returntype: 'Map',
  133. parammaps: {
  134. pastureid: Cookies.get('pastureid'),
  135. enable: '',
  136. drivername: '',
  137. drivercode: ''
  138. }
  139. },
  140. tableKey: 0,
  141. list: [],
  142. total: 0,
  143. listLoading: true
  144. },
  145. changeDetails: {
  146. dialogFormVisible: false,
  147. dialogStatus: '',
  148. getdataListParm: {
  149. name: 'getPlanModifyFPlist',
  150. page: 1,
  151. offset: 1,
  152. pagecount: 0,
  153. returntype: 'Map',
  154. parammaps: {
  155. pastureid: Cookies.get('pastureid'),
  156. enable: '',
  157. drivername: '',
  158. drivercode: ''
  159. }
  160. },
  161. tableKey: 0,
  162. list: [],
  163. total: 0,
  164. listLoading: true,
  165. spanObj: {},
  166. mergekeys: ['barname', 'sumweight']
  167. },
  168. textMap: {
  169. samplingSelection: '干物质调节—采样选择',
  170. changeDetails: '干物质调节—变化详情'
  171. },
  172. selectionList: [],
  173. isokDisable: false,
  174. requestParam: {},
  175. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  176. cellStyle: { padding: 0 + 'px' }
  177. }
  178. },
  179. watch: {
  180. // 监听show,visible 随着show变化而变化
  181. show: {
  182. immediate: true,
  183. handler(show) {
  184. this.visible = show
  185. }
  186. }
  187. },
  188. created() {
  189. },
  190. methods: {
  191. closeDialog() {
  192. this.$emit('update:show', false) // 子组件更新弹框隐藏
  193. },
  194. handleNextSamplingSelection() {
  195. if (this.temp.ftid !== '') {
  196. this.samplingSelection.dialogStatus = 'samplingSelection'
  197. this.samplingSelection.dialogFormVisible = true
  198. this.getListSamplingSelection()
  199. } else {
  200. this.$message({ type: 'error', message: '选择需调节配方', duration: 2000 })
  201. }
  202. },
  203. handleSearch() {},
  204. handleSelectionChange(item) {
  205. this.selectionList = item
  206. },
  207. getListSamplingSelection() {
  208. this.samplingSelection.listLoading = true
  209. GetDataByName(this.samplingSelection.getdataListParm).then(response => {
  210. console.log('table数据', response.data.list)
  211. if (response.data.list !== null) {
  212. this.samplingSelection.list = response.data.list
  213. this.samplingSelection.pageNum = response.data.pageNum
  214. this.samplingSelection.pageSize = response.data.pageSize
  215. this.samplingSelection.total = response.data.total
  216. } else {
  217. this.samplingSelection.list = []
  218. }
  219. setTimeout(() => {
  220. this.samplingSelection.listLoading = false
  221. }, 100)
  222. })
  223. },
  224. handleNextChangeDetails() {
  225. if (this.selectionList.length == 1) {
  226. this.changeDetails.dialogStatus = 'changeDetails'
  227. this.changeDetails.dialogFormVisible = true
  228. this.getListChangeDetails()
  229. } else {
  230. this.$message({ type: 'error', message: '选择1一条栏舍配方', duration: 2000 })
  231. }
  232. },
  233. getListChangeDetails() {
  234. this.changeDetails.listLoading = true
  235. this.changeDetails.getdataListParm.parammaps.date = '2021-04-09'
  236. GetDataByName(this.changeDetails.getdataListParm).then(response => {
  237. console.log('table数据', response.data.list)
  238. if (response.data.list !== null) {
  239. this.changeDetails.list = response.data.list
  240. this.changeDetails.pageNum = response.data.pageNum
  241. this.changeDetails.pageSize = response.data.pageSize
  242. this.changeDetails.total = response.data.total
  243. this.handleSpan()
  244. } else {
  245. this.changeDetails.list = []
  246. }
  247. setTimeout(() => {
  248. this.changeDetails.listLoading = false
  249. }, 100)
  250. })
  251. },
  252. handleSpan() {
  253. this.changeDetails.mergekeys.forEach(key => {
  254. this.changeDetails.spanObj[key] = []
  255. let position = 0
  256. this.changeDetails.list.forEach((item, index) => {
  257. if (index === 0) {
  258. this.changeDetails.spanObj[key].push(1)
  259. position = 0
  260. } else {
  261. if (key == 'sumweight') {
  262. if (this.changeDetails.list[index][key] === this.changeDetails.list[index - 1][key] && this.changeDetails.list[index]['barname'] === this.changeDetails.list[index - 1]['barname']) {
  263. this.changeDetails.spanObj[key][position] += 1
  264. this.changeDetails.spanObj[key].push(0)
  265. } else {
  266. this.changeDetails.spanObj[key].push(1)
  267. position = index
  268. }
  269. } else {
  270. if (this.changeDetails.list[index][key] === this.changeDetails.list[index - 1][key]) {
  271. this.changeDetails.spanObj[key][position] += 1
  272. this.changeDetails.spanObj[key].push(0)
  273. } else {
  274. this.changeDetails.spanObj[key].push(1)
  275. position = index
  276. }
  277. }
  278. }
  279. })
  280. })
  281. },
  282. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  283. for (let i = 0; i < this.changeDetails.mergekeys.length; i++) {
  284. if (column.property === this.changeDetails.mergekeys[i]) {
  285. const _row = this.changeDetails.spanObj[this.changeDetails.mergekeys[i]][rowIndex]
  286. const _col = _row > 0 ? 1 : 0
  287. return {
  288. rowspan: _row,
  289. colspan: _col
  290. }
  291. }
  292. }
  293. },
  294. handleNextLast() {}
  295. }
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. </style>