dffd904580fa04d822a21a05e6465c4fa8a511f9.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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; samplingSelection.frequencyList = []">上一步</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" :before-close="closeDialog" 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;samplingSelection.frequencyList = []">上一步</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. this.samplingSelection.frequencyList = []
  235. },
  236. handleNextSamplingSelection() {
  237. if (this.temp.ftid !== '') {
  238. this.samplingSelection.dialogStatus = 'samplingSelection'
  239. this.samplingSelection.dialogFormVisible = true
  240. this.getSamplingDateList()
  241. this.getSamplingSelectionDownList()
  242. } else {
  243. this.$message({ type: 'error', message: '选择需调节配方', duration: 2000 })
  244. }
  245. },
  246. getSamplingSelectionDownList() {
  247. GetDataByNames(this.samplingSelection.requestParams).then(response => {
  248. this.samplingSelection.houseNameList = response.data.getBarListEnable.list
  249. if (response.data.getSysoptEnable.list !== null) {
  250. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  251. const obj = {}
  252. obj.id = String(i)
  253. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  254. this.samplingSelection.frequencyList.push(obj)
  255. }
  256. } else {
  257. this.samplingSelection.frequencyList = []
  258. }
  259. })
  260. },
  261. getSamplingDateList() {
  262. this.samplingSelection.getdateListParm.parammaps.ftid = this.temp.ftid
  263. GetDataByName(this.samplingSelection.getdateListParm).then(response => {
  264. if (response.data.list !== null) {
  265. this.samplingSelection.dateList = response.data.list
  266. this.samplingSelection.getdataListParm.parammaps.date = response.data.list[0].date
  267. } else {
  268. this.samplingSelection.dateList = []
  269. this.samplingSelection.getdataListParm.parammaps.date = ''
  270. }
  271. this.getListSamplingSelection()
  272. })
  273. },
  274. handleSearch() {
  275. this.getListSamplingSelection()
  276. },
  277. handleSelectionChange(item) {
  278. this.selectionList = item
  279. },
  280. getListSamplingSelection() {
  281. this.samplingSelection.listLoading = true
  282. this.samplingSelection.getdataListParm.parammaps.ftid = this.temp.ftid
  283. GetDataByName(this.samplingSelection.getdataListParm).then(response => {
  284. console.log('table数据', response.data.list)
  285. if (response.data.list !== null) {
  286. this.samplingSelection.list = response.data.list
  287. this.samplingSelection.pageNum = response.data.pageNum
  288. this.samplingSelection.pageSize = response.data.pageSize
  289. this.samplingSelection.total = response.data.total
  290. } else {
  291. this.samplingSelection.list = []
  292. }
  293. setTimeout(() => {
  294. this.samplingSelection.listLoading = false
  295. }, 100)
  296. })
  297. },
  298. handleNextChangeDetails() {
  299. if (this.selectionList.length == 1) {
  300. this.changeDetails.dialogStatus = 'changeDetails'
  301. this.changeDetails.dialogFormVisible = true
  302. this.getListChangeDetails()
  303. } else {
  304. if (this.selectionList.length == 0) {
  305. this.$message({ type: 'error', message: '请选择采样内容对应干物质比例调节', duration: 2000 })
  306. } else {
  307. this.$message({ type: 'error', message: '仅可选择一条采样内容进行调节', duration: 2000 })
  308. }
  309. }
  310. },
  311. // 干物质调节—变化详情
  312. getListChangeDetails() {
  313. this.changeDetails.listLoading = true
  314. this.changeDetails.getdataListParm.parammaps.ftid = this.temp.ftid
  315. this.changeDetails.getdataListParm.parammaps.actweight = this.selectionList[0].actweight
  316. this.changeDetails.getdataListParm.parammaps.thoweight = this.selectionList[0].thoweight
  317. console.log(this.changeDetails.getdataListParm.parammaps)
  318. GetDataByName(this.changeDetails.getdataListParm).then(response => {
  319. console.log('table数据', response.data.list)
  320. if (response.data.list !== null) {
  321. this.changeDetails.list = response.data.list
  322. this.changeDetails.pageNum = response.data.pageNum
  323. this.changeDetails.pageSize = response.data.pageSize
  324. this.changeDetails.total = response.data.total
  325. this.handleSpan()
  326. } else {
  327. this.changeDetails.list = []
  328. }
  329. setTimeout(() => {
  330. this.changeDetails.listLoading = false
  331. }, 100)
  332. })
  333. },
  334. handleSpan() {
  335. this.changeDetails.mergekeys.forEach(key => {
  336. this.changeDetails.spanObj[key] = []
  337. let position = 0
  338. this.changeDetails.list.forEach((item, index) => {
  339. if (index === 0) {
  340. this.changeDetails.spanObj[key].push(1)
  341. position = 0
  342. } else {
  343. if (key == 'ftweight' || key == 'ftweightafter' || key == 'cyweight' || key == 'cyweightafter' || key == 'totalweight' || key == 'totalweightafter') {
  344. if (this.changeDetails.list[index][key] === this.changeDetails.list[index - 1][key] && this.changeDetails.list[index]['barname'] === this.changeDetails.list[index - 1]['barname']) {
  345. this.changeDetails.spanObj[key][position] += 1
  346. this.changeDetails.spanObj[key].push(0)
  347. } else {
  348. this.changeDetails.spanObj[key].push(1)
  349. position = index
  350. }
  351. } else {
  352. if (this.changeDetails.list[index][key] === this.changeDetails.list[index - 1][key]) {
  353. this.changeDetails.spanObj[key][position] += 1
  354. this.changeDetails.spanObj[key].push(0)
  355. } else {
  356. this.changeDetails.spanObj[key].push(1)
  357. position = index
  358. }
  359. }
  360. }
  361. })
  362. })
  363. },
  364. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  365. for (let i = 0; i < this.changeDetails.mergekeys.length; i++) {
  366. if (column.property === this.changeDetails.mergekeys[i]) {
  367. const _row = this.changeDetails.spanObj[this.changeDetails.mergekeys[i]][rowIndex]
  368. const _col = _row > 0 ? 1 : 0
  369. return {
  370. rowspan: _row,
  371. colspan: _col
  372. }
  373. }
  374. }
  375. },
  376. handleNextLast() {
  377. MessageBox.confirm('是否确认进行当前干物质调节操作', '提示', {
  378. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  379. // beforeClose: (action, instance, done) => {
  380. // console.log(action, instance, done)
  381. // this.closeDialog()
  382. // done()
  383. // }
  384. }).then(() => {
  385. var duplicateRemovalList = []
  386. for (let i = 0; i < this.changeDetails.list.length; i++) {
  387. for (var j = i + 1; j < this.changeDetails.list.length; j++) {
  388. if (this.changeDetails.list[i].id == this.changeDetails.list[j].id) {
  389. ++i
  390. }
  391. }
  392. duplicateRemovalList.push(this.changeDetails.list[i])
  393. }
  394. console.log(duplicateRemovalList, '=duplicateRemovalList')
  395. this.requestParam = {}
  396. this.requestParam.common = { 'returnmap': '0' }
  397. this.requestParam.data = []
  398. this.requestParam.data[0] = { 'name': 'saveFPFTdryChange', 'type': 'e', 'parammaps': {
  399. pastureid: Cookies.get('pastureid'),
  400. ftid: this.temp.ftid,
  401. actweight: this.selectionList[0].actweight,
  402. thoweight: this.selectionList[0].thoweight
  403. }}
  404. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': duplicateRemovalList }}
  405. this.requestParam.data[1].children = []
  406. this.requestParam.data[1].children[0] = { 'name': 'updateLPPbyFPChange', 'type': 'e', 'parammaps': {
  407. pastureid: '@insertSpotList.pastureid',
  408. fpid: '@insertSpotList.id'
  409. }}
  410. ExecDataByConfig(this.requestParam).then(response => {
  411. console.log('新生成保存发送参数', this.requestParam)
  412. if (response.msg === 'fail') {
  413. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  414. } else {
  415. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  416. this.closeDialog()
  417. this.$emit('getIsDisplay')
  418. }
  419. })
  420. })
  421. }
  422. }
  423. }
  424. </script>
  425. <style lang="scss" scoped>
  426. </style>