8865f4d6f6674770a972f79bc1d249a80a1684c2.svn-base 18 KB

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