8139b4660efc65862f1ae8ea0e93d81f9f18e97b.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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>
  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.tname" :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" :before-close="closeDialog" width="80%">
  20. <div class="dialogMinHeight">
  21. <div class="search filter-item">
  22. <el-select v-model="samplingSelection.getdataListParm.parammaps.date" filterable placeholder="日期" class="filter-item" style="width: 150px;">
  23. <el-option v-for="item in samplingSelection.dateList" :key="item.id" :label="item.date" :value="item.date" />
  24. </el-select>
  25. <el-select v-model="samplingSelection.getdataListParm.parammaps.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  26. <el-option v-for="item in samplingSelection.houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  27. </el-select>
  28. <el-select v-model="samplingSelection.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" clearable>
  29. <el-option v-for="item in samplingSelection.frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  30. </el-select>
  31. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  32. </div>
  33. <div class="table" style="margin-top: 10px;">
  34. <el-table
  35. :key="samplingSelection.tableKey"
  36. v-loading="samplingSelection.listLoading"
  37. element-loading-text="给我一点时间"
  38. :data="samplingSelection.list"
  39. border
  40. fit
  41. highlight-current-row
  42. style="width: 100%;"
  43. :row-style="rowStyle"
  44. :cell-style="cellStyle"
  45. class="elTable table-fixed"
  46. @selection-change="handleSelectionChange"
  47. >
  48. <el-table-column type="selection" align="center" width="50" />
  49. <el-table-column label="序号" align="center" type="index" width="50px" />
  50. <el-table-column label="栏舍名称" prop="barname" min-width="110px" align="center" />
  51. <el-table-column label="班次" prop="times" min-width="110px" align="center" />
  52. <el-table-column label="鲜样重量(g)" prop="freshweight" min-width="110px" align="center" />
  53. <el-table-column label="烘干重量(g)" prop="dryweight" min-width="110px" align="center" />
  54. <el-table-column label="理论干物质" prop="thoweight" min-width="110px" align="center" />
  55. <el-table-column label="实际干物质" prop="actweight" min-width="110px" align="center" />
  56. <el-table-column label="操作人" prop="emp" min-width="110px" align="center" />
  57. <el-table-column label="操作日期" prop="operatetime" min-width="110px" align="center" />
  58. </el-table>
  59. </div>
  60. </div>
  61. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  62. <el-button class="minCancel" @click="closeDialog();">取消</el-button>
  63. <el-button class="miniSuccess" @click="samplingSelection.dialogFormVisible=false;">上一步</el-button>
  64. <el-button class="miniSuccess" @click="handleNextChangeDetails()">下一步</el-button>
  65. </div>
  66. </el-dialog>
  67. <!-- 干物质调节-变化详情 -->
  68. <el-dialog :title="textMap[changeDetails.dialogStatus]" :visible.sync="changeDetails.dialogFormVisible" append-to-body :close-on-click-modal="false" width="80%">
  69. <div class="dialogMinHeight">
  70. <div class="table">
  71. <el-table
  72. :key="changeDetails.tableKey"
  73. v-loading="changeDetails.listLoading"
  74. element-loading-text="给我一点时间"
  75. :data="changeDetails.list"
  76. border
  77. fit
  78. highlight-current-row
  79. style="width: 100%;"
  80. :row-style="rowStyle"
  81. :cell-style="cellStyle"
  82. class="elTable table-fixed"
  83. :span-method="objectSpanMethod"
  84. >
  85. <el-table-column label="栏舍" prop="barname" min-width="70px" align="center" class-name="small-padding fixed-width" fixed="left" />
  86. <el-table-column label="班次" prop="times" min-width="70px" align="center" class-name="small-padding fixed-width" fixed="left" />
  87. <el-table-column label="调节前班次重量" prop="weight" min-width="70px" align="center" />
  88. <el-table-column label="调节后班次重量" prop="weightafter" min-width="100px" align="center" />
  89. <el-table-column label="调节前理论干物质量" prop="ftweight" min-width="70px" align="center" />
  90. <el-table-column label="调节后理论干物质量" prop="ftweightafter" min-width="90px" align="center" />
  91. <el-table-column label="调节前采样干物质量" prop="cyweight" min-width="70px" align="center" />
  92. <el-table-column label="调节后采样干物质量" prop="cyweightafter" min-width="90px" align="center" />
  93. <el-table-column label="调节前日投喂量" prop="totalweight" min-width="70px" align="center" />
  94. <el-table-column label="调节后日投喂量" prop="totalweightafter" min-width="100px" align="center" />
  95. </el-table>
  96. </div>
  97. </div>
  98. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  99. <el-button class="minCancel" @click="closeDialog();">取消</el-button>
  100. <el-button class="miniSuccess" @click="changeDetails.dialogFormVisible=false;">上一步</el-button>
  101. <el-button class="miniSuccess" @click="handleNextLast()">下一步</el-button>
  102. </div>
  103. </el-dialog>
  104. </div>
  105. </template>
  106. <script>
  107. import { GetDataByName, GetDataByNames, ExecDataByConfig } from '@/api/common'
  108. import { parseTime, handleTableSpan, handleObjectSpanMethod } from '@/utils/index.js'
  109. import Cookies from 'js-cookie'
  110. import { MessageBox } from 'element-ui'
  111. export default {
  112. name: 'RevisePlan',
  113. components: {},
  114. props: {
  115. show: { type: Boolean, default: false }
  116. },
  117. data() {
  118. return {
  119. visible: this.show,
  120. dialogFormVisible: false,
  121. dialogStatus: '',
  122. balconicFormulaListParm: {
  123. name: 'getFTSWList',
  124. page: 1,
  125. offset: 1,
  126. pagecount: 0,
  127. returntype: 'Map',
  128. parammaps: {
  129. pastureid: Cookies.get('pastureid')
  130. }
  131. },
  132. balconicFormulaList: [],
  133. temp: {
  134. ftid: ''
  135. },
  136. samplingSelection: {
  137. dialogFormVisible: false,
  138. dialogStatus: '',
  139. dateList: [],
  140. getdateListParm: {
  141. name: 'getftdrydatelist',
  142. offset: 0,
  143. pagecount: 30,
  144. parammaps: { pastureid: Cookies.get('pastureid') }
  145. },
  146. requestParams: [
  147. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }},
  148. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }}
  149. ],
  150. houseNameList: [], // 栏舍名称
  151. frequencyList: [], // 班次
  152. getdataListParm: {
  153. name: 'getftdrycylist',
  154. page: 1,
  155. offset: 1,
  156. pagecount: 0,
  157. returntype: 'Map',
  158. parammaps: {
  159. pastureid: Cookies.get('pastureid'),
  160. ftid: '',
  161. date: '',
  162. barid: '',
  163. times: ''
  164. }
  165. },
  166. tableKey: 0,
  167. list: [],
  168. total: 0,
  169. listLoading: true
  170. },
  171. changeDetails: {
  172. dialogFormVisible: false,
  173. dialogStatus: '',
  174. getdataListParm: {
  175. name: 'getftdryafterlist',
  176. page: 1,
  177. offset: 1,
  178. pagecount: 0,
  179. returntype: 'Map',
  180. parammaps: {
  181. pastureid: Cookies.get('pastureid'),
  182. ftid: '',
  183. actweight: '',
  184. thoweight: ''
  185. }
  186. },
  187. tableKey: 1,
  188. list: [],
  189. total: 0,
  190. listLoading: true,
  191. spanObj: {},
  192. mergekeys: ['barname', 'ftweight', 'ftweightafter', 'cyweight', 'cyweightafter', 'totalweight', 'totalweightafter']
  193. },
  194. textMap: {
  195. samplingSelection: '干物质调节—采样选择',
  196. changeDetails: '干物质调节—变化详情'
  197. },
  198. selectionList: [],
  199. isokDisable: false,
  200. requestParam: {},
  201. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  202. cellStyle: { padding: 0 + 'px' }
  203. }
  204. },
  205. watch: {
  206. // 监听show,visible 随着show变化而变化
  207. show: {
  208. immediate: true,
  209. handler(show) {
  210. this.visible = show
  211. }
  212. }
  213. },
  214. created() {
  215. },
  216. methods: {
  217. restTemp() {
  218. this.temp.ftid = ''
  219. },
  220. getBalconicFormula() {
  221. GetDataByName(this.balconicFormulaListParm).then(response => {
  222. console.log('栏舍配方数据', response.data.list)
  223. if (response.data.list !== null) {
  224. this.balconicFormulaList = response.data.list
  225. } else {
  226. this.balconicFormulaList = []
  227. }
  228. })
  229. },
  230. closeDialog() {
  231. this.$emit('update:show', false) // 子组件更新弹框隐藏
  232. this.samplingSelection.dialogFormVisible = false
  233. this.changeDetails.dialogFormVisible = false
  234. },
  235. handleNextSamplingSelection() {
  236. if (this.temp.ftid !== '') {
  237. this.samplingSelection.dialogStatus = 'samplingSelection'
  238. this.samplingSelection.dialogFormVisible = true
  239. this.getSamplingDateList()
  240. this.getSamplingSelectionDownList()
  241. } else {
  242. this.$message({ type: 'error', message: '选择需调节配方', duration: 2000 })
  243. }
  244. },
  245. getSamplingSelectionDownList() {
  246. GetDataByNames(this.samplingSelection.requestParams).then(response => {
  247. this.samplingSelection.houseNameList = response.data.getBarListEnable.list
  248. if (response.data.getSysoptEnable.list !== null) {
  249. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  250. const obj = {}
  251. obj.id = String(i)
  252. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  253. this.samplingSelection.frequencyList.push(obj)
  254. }
  255. } else {
  256. this.samplingSelection.frequencyList = []
  257. }
  258. })
  259. },
  260. getSamplingDateList() {
  261. this.samplingSelection.getdateListParm.parammaps.ftid = this.temp.ftid
  262. GetDataByName(this.samplingSelection.getdateListParm).then(response => {
  263. if (response.data.list !== null) {
  264. this.samplingSelection.dateList = response.data.list
  265. this.samplingSelection.getdataListParm.parammaps.date = response.data.list[0].date
  266. } else {
  267. this.samplingSelection.dateList = []
  268. this.samplingSelection.getdataListParm.parammaps.date = ''
  269. }
  270. this.getListSamplingSelection()
  271. })
  272. },
  273. handleSearch() {
  274. this.getListSamplingSelection()
  275. },
  276. handleSelectionChange(item) {
  277. this.selectionList = item
  278. },
  279. getListSamplingSelection() {
  280. this.samplingSelection.listLoading = true
  281. this.samplingSelection.getdataListParm.parammaps.ftid = this.temp.ftid
  282. GetDataByName(this.samplingSelection.getdataListParm).then(response => {
  283. console.log('table数据', response.data.list)
  284. if (response.data.list !== null) {
  285. this.samplingSelection.list = response.data.list
  286. this.samplingSelection.pageNum = response.data.pageNum
  287. this.samplingSelection.pageSize = response.data.pageSize
  288. this.samplingSelection.total = response.data.total
  289. } else {
  290. this.samplingSelection.list = []
  291. }
  292. setTimeout(() => {
  293. this.samplingSelection.listLoading = false
  294. }, 100)
  295. })
  296. },
  297. handleNextChangeDetails() {
  298. if (this.selectionList.length == 1) {
  299. this.changeDetails.dialogStatus = 'changeDetails'
  300. this.changeDetails.dialogFormVisible = true
  301. this.getListChangeDetails()
  302. } else {
  303. if (this.selectionList.length == 0) {
  304. this.$message({ type: 'error', message: '请选择采样内容对应干物质比例调节', duration: 2000 })
  305. } else {
  306. this.$message({ type: 'error', message: '仅可选择一条采样内容进行调节', duration: 2000 })
  307. }
  308. }
  309. },
  310. // 干物质调节—变化详情
  311. getListChangeDetails() {
  312. this.changeDetails.listLoading = true
  313. this.changeDetails.getdataListParm.parammaps.ftid = this.temp.ftid
  314. this.changeDetails.getdataListParm.parammaps.actweight = this.selectionList[0].actweight
  315. this.changeDetails.getdataListParm.parammaps.thoweight = this.selectionList[0].thoweight
  316. console.log(this.changeDetails.getdataListParm.parammaps)
  317. GetDataByName(this.changeDetails.getdataListParm).then(response => {
  318. console.log('table数据', response.data.list)
  319. if (response.data.list !== null) {
  320. this.changeDetails.list = response.data.list
  321. this.changeDetails.pageNum = response.data.pageNum
  322. this.changeDetails.pageSize = response.data.pageSize
  323. this.changeDetails.total = response.data.total
  324. this.handleSpan()
  325. } else {
  326. this.changeDetails.list = []
  327. }
  328. setTimeout(() => {
  329. this.changeDetails.listLoading = false
  330. }, 100)
  331. })
  332. },
  333. handleSpan() {
  334. this.changeDetails.mergekeys.forEach(key => {
  335. this.changeDetails.spanObj[key] = []
  336. let position = 0
  337. this.changeDetails.list.forEach((item, index) => {
  338. if (index === 0) {
  339. this.changeDetails.spanObj[key].push(1)
  340. position = 0
  341. } else {
  342. if (key == 'ftweight' || key == 'ftweightafter' || key == 'cyweight' || key == 'cyweightafter' || key == 'totalweight' || key == 'totalweightafter') {
  343. if (this.changeDetails.list[index][key] === this.changeDetails.list[index - 1][key] && this.changeDetails.list[index]['barname'] === this.changeDetails.list[index - 1]['barname']) {
  344. this.changeDetails.spanObj[key][position] += 1
  345. this.changeDetails.spanObj[key].push(0)
  346. } else {
  347. this.changeDetails.spanObj[key].push(1)
  348. position = index
  349. }
  350. } else {
  351. if (this.changeDetails.list[index][key] === this.changeDetails.list[index - 1][key]) {
  352. this.changeDetails.spanObj[key][position] += 1
  353. this.changeDetails.spanObj[key].push(0)
  354. } else {
  355. this.changeDetails.spanObj[key].push(1)
  356. position = index
  357. }
  358. }
  359. }
  360. })
  361. })
  362. },
  363. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  364. for (let i = 0; i < this.changeDetails.mergekeys.length; i++) {
  365. if (column.property === this.changeDetails.mergekeys[i]) {
  366. const _row = this.changeDetails.spanObj[this.changeDetails.mergekeys[i]][rowIndex]
  367. const _col = _row > 0 ? 1 : 0
  368. return {
  369. rowspan: _row,
  370. colspan: _col
  371. }
  372. }
  373. }
  374. },
  375. handleNextLast() {
  376. MessageBox.confirm('是否确认进行当前干物质调节操作', '提示', {
  377. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  378. // beforeClose: (action, instance, done) => {
  379. // console.log(action, instance, done)
  380. // this.closeDialog()
  381. // done()
  382. // }
  383. }).then(() => {
  384. var duplicateRemovalList = []
  385. for (let i = 0; i < this.changeDetails.list.length; i++) {
  386. for (var j = i + 1; j < this.changeDetails.list.length; j++) {
  387. if (this.changeDetails.list[i].id == this.changeDetails.list[j].id) {
  388. ++i
  389. }
  390. }
  391. duplicateRemovalList.push(this.changeDetails.list[i])
  392. }
  393. console.log(duplicateRemovalList, '=duplicateRemovalList')
  394. this.requestParam = {}
  395. this.requestParam.common = { 'returnmap': '0' }
  396. this.requestParam.data = []
  397. this.requestParam.data[0] = { 'name': 'saveFPFTdryChange', 'type': 'e', 'parammaps': {
  398. pastureid: Cookies.get('pastureid'),
  399. ftid: this.temp.ftid,
  400. actweight: this.selectionList[0].actweight,
  401. thoweight: this.selectionList[0].thoweight
  402. }}
  403. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': duplicateRemovalList }}
  404. this.requestParam.data[1].children = []
  405. this.requestParam.data[1].children[0] = { 'name': 'updateLPPbyFPChange', 'type': 'e', 'parammaps': {
  406. pastureid: '@insertSpotList.pastureid',
  407. fpid: '@insertSpotList.id'
  408. }}
  409. ExecDataByConfig(this.requestParam).then(response => {
  410. console.log('新生成保存发送参数', this.requestParam)
  411. if (response.msg === 'fail') {
  412. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  413. } else {
  414. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  415. this.closeDialog()
  416. this.$emit('getIsDisplay')
  417. }
  418. })
  419. })
  420. }
  421. }
  422. }
  423. </script>
  424. <style lang="scss" scoped>
  425. </style>