349c4c92eeeb4d4ab128218fb6f4d307c761d7e1.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. this.samplingSelection.dialogFormVisible = false
  194. this.changeDetails.dialogFormVisible = false
  195. },
  196. handleNextSamplingSelection() {
  197. if (this.temp.ftid !== '') {
  198. this.samplingSelection.dialogStatus = 'samplingSelection'
  199. this.samplingSelection.dialogFormVisible = true
  200. this.getListSamplingSelection()
  201. } else {
  202. this.$message({ type: 'error', message: '选择需调节配方', duration: 2000 })
  203. }
  204. },
  205. handleSearch() {},
  206. handleSelectionChange(item) {
  207. this.selectionList = item
  208. },
  209. getListSamplingSelection() {
  210. this.samplingSelection.listLoading = true
  211. GetDataByName(this.samplingSelection.getdataListParm).then(response => {
  212. console.log('table数据', response.data.list)
  213. if (response.data.list !== null) {
  214. this.samplingSelection.list = response.data.list
  215. this.samplingSelection.pageNum = response.data.pageNum
  216. this.samplingSelection.pageSize = response.data.pageSize
  217. this.samplingSelection.total = response.data.total
  218. } else {
  219. this.samplingSelection.list = []
  220. }
  221. setTimeout(() => {
  222. this.samplingSelection.listLoading = false
  223. }, 100)
  224. })
  225. },
  226. handleNextChangeDetails() {
  227. if (this.selectionList.length == 1) {
  228. this.changeDetails.dialogStatus = 'changeDetails'
  229. this.changeDetails.dialogFormVisible = true
  230. this.getListChangeDetails()
  231. } else {
  232. if (this.selectionList.length == 0) {
  233. this.$message({ type: 'error', message: '请选择采样内容对应干物质比例调节', duration: 2000 })
  234. } else {
  235. this.$message({ type: 'error', message: '仅可选择一条采样内容进行调节', duration: 2000 })
  236. }
  237. }
  238. },
  239. getListChangeDetails() {
  240. this.changeDetails.listLoading = true
  241. this.changeDetails.getdataListParm.parammaps.date = '2021-04-09'
  242. GetDataByName(this.changeDetails.getdataListParm).then(response => {
  243. console.log('table数据', response.data.list)
  244. if (response.data.list !== null) {
  245. this.changeDetails.list = response.data.list
  246. this.changeDetails.pageNum = response.data.pageNum
  247. this.changeDetails.pageSize = response.data.pageSize
  248. this.changeDetails.total = response.data.total
  249. this.handleSpan()
  250. } else {
  251. this.changeDetails.list = []
  252. }
  253. setTimeout(() => {
  254. this.changeDetails.listLoading = false
  255. }, 100)
  256. })
  257. },
  258. handleSpan() {
  259. this.changeDetails.mergekeys.forEach(key => {
  260. this.changeDetails.spanObj[key] = []
  261. let position = 0
  262. this.changeDetails.list.forEach((item, index) => {
  263. if (index === 0) {
  264. this.changeDetails.spanObj[key].push(1)
  265. position = 0
  266. } else {
  267. if (key == 'sumweight') {
  268. if (this.changeDetails.list[index][key] === this.changeDetails.list[index - 1][key] && this.changeDetails.list[index]['barname'] === this.changeDetails.list[index - 1]['barname']) {
  269. this.changeDetails.spanObj[key][position] += 1
  270. this.changeDetails.spanObj[key].push(0)
  271. } else {
  272. this.changeDetails.spanObj[key].push(1)
  273. position = index
  274. }
  275. } else {
  276. if (this.changeDetails.list[index][key] === this.changeDetails.list[index - 1][key]) {
  277. this.changeDetails.spanObj[key][position] += 1
  278. this.changeDetails.spanObj[key].push(0)
  279. } else {
  280. this.changeDetails.spanObj[key].push(1)
  281. position = index
  282. }
  283. }
  284. }
  285. })
  286. })
  287. },
  288. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  289. for (let i = 0; i < this.changeDetails.mergekeys.length; i++) {
  290. if (column.property === this.changeDetails.mergekeys[i]) {
  291. const _row = this.changeDetails.spanObj[this.changeDetails.mergekeys[i]][rowIndex]
  292. const _col = _row > 0 ? 1 : 0
  293. return {
  294. rowspan: _row,
  295. colspan: _col
  296. }
  297. }
  298. }
  299. },
  300. handleNextLast() {
  301. MessageBox.confirm('是否确认进行当前干物质调节操作', '提示', {
  302. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning',
  303. beforeClose: (action, instance, done) => {
  304. console.log(action, instance, done)
  305. this.closeDialog()
  306. done()
  307. }
  308. }).then(() => {
  309. })
  310. }
  311. }
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. </style>