ad95e3eeb932d023751f8d85c40c3bb762fdd529.svn-base 18 KB

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