999f76bb2902bc1334455b089ab54ffc94759507.svn-base 20 KB

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