65fa1a5874c6565ad998d3d76d5218a8001e88bb.svn-base 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" style="float: left;" @click="handleCreate">新增车次</el-button>
  5. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" style="float: left;" @click="handleDelete">减少车次</el-button>
  6. <el-button v-if="isRoleEdit" class="success" style="float: left;" @click="handleCheck">校验</el-button>
  7. <el-button class="import" style="float: right;" @click="handleHistoryRecords">历史记录</el-button>
  8. </div>
  9. <div class="search" />
  10. <div class="table">
  11. <el-table
  12. id="table"
  13. :key="table.tableKey"
  14. v-loading="table.listLoading"
  15. element-loading-text="给我一点时间"
  16. :data="table.list"
  17. border
  18. fit
  19. highlight-current-row
  20. style="width: 100%;"
  21. :row-style="rowStyle"
  22. :cell-style="cellStyle"
  23. class="elTable table-fixed"
  24. row-key="id"
  25. @selection-change="handleSelect"
  26. >
  27. <el-table-column type="selection" min-width="50" />
  28. <el-table-column label="车次" min-width="80px" align="center">
  29. <template slot-scope="scope">
  30. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  31. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" type="number" style="width:95%;padding:10px 0;" />
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="栏舍" min-width="110px" align="center">
  35. <template slot-scope="scope">
  36. <span v-if="scope.row.NoEdit">{{ scope.row.qstr }}</span>
  37. <el-select v-if="scope.row.Edit" v-model="scope.row.barid" multiple filterable placeholder="栏舍名称" class="filter-item" style="width:95%;padding:10px 0;" @change="changeBars">
  38. <el-option v-for="item in barsList" :key="item.id" :label="item.bname" :value="item.id" />
  39. </el-select>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="TMR编号" prop="weight" min-width="110px" align="center">
  43. <template slot-scope="scope">
  44. <span v-if="scope.row.NoEdit">{{ scope.row.tmrcode }}</span>
  45. <el-select v-if="scope.row.Edit" v-model="scope.row.tmrid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeTMRNumber(value, scope.row)}">
  46. <el-option v-for="item in TMRNumberList" :key="item.id" :label="item.tname" :value="item.id" />
  47. </el-select>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="生效" min-width="70px" align="center">
  51. <template slot-scope="scope">
  52. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="班次" min-width="120px" align="center">
  56. <template slot-scope="scope">
  57. <span v-if="scope.row.NoEdit">{{ scope.row.times }}</span>
  58. <el-select v-if="scope.row.Edit" v-model="scope.row.times" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeTimes(value, scope.row)}">
  59. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  60. </el-select>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="撒料计划车次跟随" min-width="90px" align="center">
  64. <template slot-scope="scope">
  65. <span v-if="scope.row.NoEdit">{{ scope.row.lppcode }}</span>
  66. <el-select v-if="scope.row.Edit" v-model="scope.row.lppid" filterable clearable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeCarFollow(value, scope.row)}">
  67. <el-option v-for="item in carFollowList" :key="item.id" :label="item.lppcode" :value="item.id" />
  68. </el-select>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="时间" min-width="130px" align="center">
  72. <template slot-scope="scope">
  73. <span v-if="scope.row.NoEdit">{{ scope.row.rtime }}</span>
  74. <el-time-picker v-if="scope.row.Edit" v-model="scope.row.rtime" type="datetime" placeholder="选择时间" format="HH:mm" value-format="HH:mm" style="display: inline-block;width: 95%;" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="剩料处理方式" min-width="130px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.treatmethod }}</span>
  80. <el-select v-if="scope.row.Edit" v-model="scope.row.treatmethod" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeResidueDisposal(value, scope.row)}">
  81. <el-option v-for="item in residueDisposalList" :key="item.value" :label="item.label" :value="item.label" />
  82. </el-select>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="转投栏舍" min-width="130px" align="center">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.NoEdit">{{ scope.row.hstr }}</span>
  88. <el-select v-if="scope.row.Edit" v-model="scope.row.useinbarid" :disabled="scope.row.treatmethod == '继续饲喂'" multiple filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="changeTransferbars">
  89. <el-option v-for="item in transferbarsList" :key="item.id" :label="item.bname" :value="item.id" />
  90. </el-select>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  94. <template slot-scope="{row}">
  95. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  96. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  97. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  98. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  99. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  100. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  101. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  102. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  103. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">共{{ table.total }}条</span>
  108. </div>
  109. <!-- 历史记录 -->
  110. <el-dialog :title="textMap[history.dialogStatus]" :destroy-on-close="true" :visible.sync="history.dialogFormVisible" :close-on-click-modal="false" width="90%">
  111. <div class="app-history">
  112. <div class="search">
  113. <el-date-picker v-model="history.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  114. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  115. </div>
  116. <div class="table">
  117. <el-table
  118. :key="history.tableKey"
  119. v-loading="history.listLoading"
  120. element-loading-text="给我一点时间"
  121. :data="history.list"
  122. border
  123. fit
  124. highlight-current-row
  125. style="width: 100%;"
  126. :row-style="rowStyle"
  127. :cell-style="cellStyle"
  128. class="elTable table-fixed"
  129. >
  130. <el-table-column label="车次" min-width="130px" align="center">
  131. <template slot-scope="scope">
  132. <span>{{ scope.row.sort }}</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="栏舍" min-width="130px" align="center">
  136. <template slot-scope="scope">
  137. <span>{{ scope.row.qstr }}</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="TMR编号" prop="weight" min-width="130px" align="center">
  141. <template slot-scope="scope">
  142. <span>{{ scope.row.tmrcode }}</span>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="生效" min-width="130px" align="center">
  146. <template slot-scope="scope">
  147. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="班次" min-width="130px" align="center">
  151. <template slot-scope="scope">
  152. <span>{{ scope.row.times }}</span>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="发料计划车次跟随" min-width="130px" align="center">
  156. <template slot-scope="scope">
  157. <span>{{ scope.row.lppcode }}</span>
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="时间" min-width="180px" align="center">
  161. <template slot-scope="scope">
  162. <span>{{ scope.row.rtime }}</span>
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="剩料处理方式" min-width="130px" align="center">
  166. <template slot-scope="scope">
  167. <span>{{ scope.row.treatmethod }}</span>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="转投栏舍" min-width="130px" align="center">
  171. <template slot-scope="scope">
  172. <span>{{ scope.row.hstr }}</span>
  173. </template>
  174. </el-table-column>
  175. </el-table>
  176. <pagination v-show="history.total>0" :total="history.total" :page.sync="history.getdataListParm.offset" :limit.sync="history.getdataListParm.pagecount" @pagination="getHistoryList" />
  177. </div>
  178. </div>
  179. <div slot="footer" class="dialog-footer">
  180. <el-button class="cancelClose cancelClose1" @click="history.dialogFormVisible = false; ">关闭</el-button>
  181. </div>
  182. </el-dialog>
  183. <el-dialog :title="textMap[check.dialogStatus]" :destroy-on-close="true" :visible.sync="check.dialogFormVisible" :close-on-click-modal="false" width="30%">
  184. <div class="check">
  185. <p v-if="check.temp.isDistribution == '0'">当前有栏舍未分配,建议及时进行分配,未分配栏舍如下:</p>
  186. <p v-else>已分配完:当前栏舍已分配完善</p>
  187. {{ check.temp.bnames }}
  188. </div>
  189. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  190. <el-button class="save" @click="check.dialogFormVisible=false;">确认</el-button>
  191. </div>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig, checkButtons } from '@/api/common'
  197. import Pagination from '@/components/Pagination'
  198. import Sortable from 'sortablejs'
  199. import Cookies from 'js-cookie'
  200. import { MessageBox } from 'element-ui'
  201. export default {
  202. name: 'SurplusMaterialPlan',
  203. components: { Pagination },
  204. data() {
  205. return {
  206. isRoleEdit: [],
  207. requestParams: [
  208. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  209. { name: 'getTMRYHList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  210. ],
  211. barsList: [], // 栏舍
  212. residueDisposalList: [{ value: '0', label: '转投剩料' }, { value: '1', label: '继续饲喂' }], // 剩料处理方式
  213. TMRNumberList: [], // TMR编号
  214. barsNamesIdTempArr: [],
  215. useinbarNamesIdTempArr: [],
  216. // 班次
  217. maxTime: {
  218. getMaxTimesParm: {
  219. name: 'getSysoptEnable',
  220. page: 1,
  221. offset: 1,
  222. pagecount: 1,
  223. returntype: 'Map',
  224. parammaps: {
  225. pastureid: Cookies.get('pastureid'),
  226. inforname: 'times'
  227. }
  228. }
  229. },
  230. frequencyList: [], // 班次
  231. getCarFollowParm: {
  232. name: 'getLPPCodeList',
  233. offset: 0,
  234. pagecount: 0,
  235. parammaps: {
  236. pastureid: Cookies.get('pastureid'),
  237. times: ''
  238. }
  239. },
  240. carFollowList: [], // 发料计划车次跟随
  241. getTransferbarsParm: {
  242. name: 'getBarListEnable',
  243. offset: 0,
  244. pagecount: 0,
  245. parammaps: {
  246. pastureid: Cookies.get('pastureid'),
  247. times: ''
  248. }
  249. },
  250. transferbarsList: [], // 转头栏舍
  251. table: {
  252. getdataListParm: {
  253. name: 'getRemainplanList',
  254. page: 1,
  255. offset: 1,
  256. pagecount: '',
  257. returntype: 'Map',
  258. parammaps: {
  259. pastureid: Cookies.get('pastureid')
  260. }
  261. },
  262. tableKey: 0,
  263. list: [],
  264. total: 0,
  265. listLoading: true,
  266. temp: {},
  267. temp2: {}
  268. },
  269. history: {
  270. dialogFormVisible: false,
  271. dialogStatus: '',
  272. temp: {},
  273. rules: {},
  274. tableKey: 0,
  275. list: [],
  276. total: 0,
  277. listLoading: true,
  278. getdataDateParm: {
  279. name: 'getRPMaxDate',
  280. page: 1,
  281. offset: 1,
  282. pagecount: 10,
  283. returntype: 'Map',
  284. parammaps: {
  285. pastureid: Cookies.get('pastureid')
  286. }
  287. },
  288. getdataListParm: {
  289. name: 'getRemainplanListDate',
  290. page: 1,
  291. offset: 1,
  292. pagecount: 10,
  293. returntype: 'Map',
  294. parammaps: {
  295. pastureid: Cookies.get('pastureid'),
  296. date: ''
  297. }
  298. }
  299. },
  300. check: {
  301. dialogFormVisible: false,
  302. dialogStatus: '',
  303. getCheckParm: {
  304. name: 'checkRemainplan',
  305. page: 1,
  306. offset: 1,
  307. pagecount: 10,
  308. returntype: 'Map',
  309. parammaps: {
  310. pastureid: Cookies.get('pastureid')
  311. }
  312. },
  313. temp: {
  314. bnames: '',
  315. isDistribution: ''
  316. }
  317. },
  318. textMap: {
  319. history: '历史记录',
  320. check: '提示'
  321. },
  322. requestParam: {},
  323. selectList: [],
  324. isokDisable: false,
  325. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  326. cellStyle: { padding: 0 + 'px' },
  327. dropState: false
  328. }
  329. },
  330. created() {
  331. this.getButtons()
  332. this.getList()
  333. this.getDownList()
  334. this.getIsDisplay()
  335. },
  336. methods: {
  337. getButtons() {
  338. const Edit = 'SurplusMaterialPlan'
  339. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  340. this.isRoleEdit = isRoleEdit
  341. },
  342. getDownList() {
  343. GetDataByNames(this.requestParams).then(response => {
  344. this.barsList = response.data.getBarListEnable.list
  345. this.TMRNumberList = response.data.getTMRYHList.list
  346. })
  347. },
  348. getIsDisplay() {
  349. GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
  350. if (response.data.list[0].inforvalue == 1) {
  351. this.frequencyList = [{ id: '1', name: '第一班' }]
  352. } else if (response.data.list[0].inforvalue == 2) {
  353. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
  354. } else if (response.data.list[0].inforvalue == 3) {
  355. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  356. } else if (response.data.list[0].inforvalue == 4) {
  357. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  358. }
  359. })
  360. },
  361. getList() {
  362. this.table.listLoading = true
  363. GetDataByName(this.table.getdataListParm).then(response => {
  364. console.log('table数据', response.data.list)
  365. if (response.data.list !== null) {
  366. for (let i = 0; i < response.data.list.length; i++) {
  367. this.$set(response.data.list[i], 'Edit', false) // 编辑
  368. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  369. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  370. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  371. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  372. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  373. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  374. }
  375. var arr = response.data.list
  376. arr.map(function(i, j) {
  377. // console.log(i, '====')
  378. if (i.qstrids) {
  379. return i.barid = i.qstrids.split(',')
  380. } else {
  381. return i.barid = []
  382. }
  383. })
  384. arr.map(function(i, j) {
  385. if (i.hstrids) {
  386. return i.useinbarid = i.hstrids.split(',')
  387. } else {
  388. return i.useinbarid = []
  389. }
  390. })
  391. this.table.list = arr
  392. // this.table.list = response.data.list
  393. this.table.pageNum = response.data.pageNum
  394. this.table.pageSize = response.data.pageSize
  395. this.rowDrop()
  396. this.table.total = response.data.total
  397. } else {
  398. this.table.list = []
  399. }
  400. setTimeout(() => {
  401. this.table.listLoading = false
  402. }, 100)
  403. })
  404. },
  405. handleEnableChange() {
  406. console.log('点击了生效')
  407. },
  408. // 行拖拽
  409. rowDrop() {
  410. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  411. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  412. const that = this
  413. var sortable = Sortable.create(tbody, {
  414. disabled: that.dropState,
  415. onChoose({ newIndex, oldIndex }) {
  416. if (that.dropState == true) {
  417. sortable.destroy()
  418. }
  419. },
  420. onEnd({ newIndex, oldIndex }) {
  421. const currRow = that.table.list.splice(oldIndex, 1)[0]
  422. that.table.list.splice(newIndex, 0, currRow)
  423. console.log('索引', newIndex)
  424. console.log('拖动数据', currRow)
  425. console.log('上', that.table.list[newIndex - 1])
  426. console.log('下', that.table.list[newIndex + 1])
  427. }
  428. })
  429. },
  430. // 模板新增
  431. handleCreate() {
  432. console.log('点击了新增车次')
  433. // 编辑true/不可编辑false
  434. // 新增操true,编辑false,编辑保存false
  435. this.dropState = true
  436. for (let i = 0; i < this.table.list.length; i++) {
  437. if (this.table.list[i].Edit === true) {
  438. console.log(123)
  439. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  440. return false
  441. }
  442. }
  443. var sort = 1
  444. if (this.table.list.length > 0) {
  445. sort = parseInt(this.table.list[this.table.list.length - 1].sort) + 1
  446. } else {
  447. sort = 1
  448. }
  449. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'sort': sort, 'ftid': '', 'ftname': '', 'tmrcode': '', 'tmrid': '', 'times': '', 'lppcode': '', 'lppid': '', 'rtime': '', barid: '', 'treatmethod': '', 'useinbar': '', 'useinbarid': '' })
  450. console.log(this.table.list)
  451. },
  452. // 栏舍
  453. changeBars(val) {
  454. console.log('点击了栏舍', val)
  455. var arr = []
  456. this.barsList.forEach(function(i) {
  457. val.forEach(function(j) {
  458. if (i.id == j) { arr.push(i) }
  459. })
  460. })
  461. console.log('点击了栏舍', arr)
  462. this.table.temp.barid = arr
  463. this.barsNamesIdTempArr = arr
  464. this.$forceUpdate()
  465. },
  466. // TMR编号
  467. changeTMRNumber(item, row) {
  468. row.tmrcode = this.TMRNumberList.find(obj => obj.id == item).tname
  469. },
  470. // 撒料计划车次跟随列表
  471. changeCarFollow(item, row) {
  472. if (item == '') {
  473. row.lppcode = ''
  474. } else {
  475. row.lppcode = this.carFollowList.find(obj => obj.id == item).lppcode
  476. }
  477. },
  478. // 班次
  479. changeTimes(item, row) {
  480. console.log(item, row)
  481. this.getCarFollowParm.parammaps.times = item
  482. this.getCarFollowList(row)
  483. },
  484. // 撒料计划车次跟随列表
  485. getCarFollowList(row) {
  486. GetDataByName(this.getCarFollowParm).then(response => {
  487. console.log('撒料计划车次跟随列表数据', response.data.list)
  488. if (response.data.list !== null) {
  489. this.carFollowList = response.data.list
  490. row.lppid = this.carFollowList[0].id
  491. row.lppcode = this.carFollowList[0].lppcode
  492. }
  493. })
  494. },
  495. changeResidueDisposal(item, row) {
  496. console.log(item, row)
  497. this.getCarFollowParm.parammaps.times = item
  498. this.getTransferbarsList()
  499. },
  500. getTransferbarsList() {
  501. GetDataByName(this.getTransferbarsParm).then(response => {
  502. if (response.data.list !== null) {
  503. this.transferbarsList = response.data.list
  504. }
  505. })
  506. },
  507. // 转头栏舍
  508. changeTransferbars(val) {
  509. console.log('点击了转头栏舍', val)
  510. var arr2 = []
  511. this.transferbarsList.forEach(function(i) {
  512. val.forEach(function(j) {
  513. if (i.id == j) { arr2.push(i) }
  514. })
  515. })
  516. this.table.temp2.useinbar = arr2
  517. this.useinbarNamesIdTempArr = arr2
  518. this.$forceUpdate()
  519. },
  520. createData(row) {
  521. console.log('点击了新增保存', row)
  522. if (row.rtime == null || row.rtime == 'null') {
  523. row.rtime = ''
  524. }
  525. if (row.sort == '' && row.barid == '' && row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  526. this.$message({ type: 'error', message: '车次/栏舍/TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  527. return false
  528. } else if (row.barid == '' && row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  529. this.$message({ type: 'error', message: '栏舍/TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  530. return false
  531. } else if (row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  532. this.$message({ type: 'error', message: 'TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  533. return false
  534. } else if (row.times == '' && row.treatmethod == '') {
  535. this.$message({ type: 'error', message: '班次/剩料处理方式不能为空', duration: 2000 })
  536. return false
  537. } else if (row.sort == '' || row.sort == 0) {
  538. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  539. return false
  540. } else if (row.barid == '') {
  541. this.$message({ type: 'error', message: '栏舍不能为空', duration: 2000 })
  542. return false
  543. } else if (row.tmrid == '') {
  544. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  545. return false
  546. } else if (row.times == '') {
  547. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  548. return false
  549. } else if (row.treatmethod == '') {
  550. this.$message({ type: 'error', message: '剩料处理方式不能为空', duration: 2000 })
  551. return false
  552. }
  553. if (row.treatmethod !== '' && row.treatmethod == '转投剩料') {
  554. if (row.useinbarid == '') {
  555. this.$message({ type: 'error', message: '转投栏舍不能为空', duration: 2000 })
  556. return false
  557. }
  558. }
  559. if (row.treatmethod !== '' && row.treatmethod == '继续饲喂') {
  560. row.useinbarid = '0'
  561. }
  562. if (row.rtime == '' || row.rtime == null) {
  563. row.rtime = ''
  564. }
  565. for (let i = 0; i < this.table.list.length; i++) {
  566. if (row.sort == this.table.list[i].sort) {
  567. if (row.myId !== this.table.list[i].myId) {
  568. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  569. return false
  570. }
  571. }
  572. }
  573. var isInteger = /^\d+$/
  574. if (row.sort !== '') {
  575. if (!isInteger.test(parseFloat(row.sort))) {
  576. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  577. return false
  578. }
  579. }
  580. this.isokDisable = true
  581. setTimeout(() => {
  582. this.isokDisable = false
  583. }, 1000)
  584. this.requestParam.common = { 'returnmap': '0' }
  585. this.requestParam.data = []
  586. this.requestParam.data[0] = { 'name': 'insertRemainplan', 'type': 'e', 'parammaps': {
  587. pastureid: Cookies.get('pastureid'),
  588. sort: row.sort,
  589. tmrid: row.tmrid,
  590. tmrcode: row.tmrcode,
  591. enable: row.enable,
  592. times: row.times,
  593. lppid: row.lppid,
  594. lppcode: row.lppcode,
  595. rtime: row.rtime,
  596. treatmethod: row.treatmethod
  597. }}
  598. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.barsNamesIdTempArr }}
  599. this.requestParam.data[1].children = []
  600. this.requestParam.data[1].children[0] = { 'name': 'insertRpdetail', 'type': 'e', 'parammaps': {
  601. pastureid: Cookies.get('pastureid'),
  602. bigid: '@insertRemainplan.LastInsertId',
  603. barid: '@insertSpotList.id',
  604. bar: '@insertSpotList.bname',
  605. type: 0
  606. }}
  607. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.useinbarNamesIdTempArr }}
  608. this.requestParam.data[2].children = []
  609. this.requestParam.data[2].children[0] = { 'name': 'insertRpdetail', 'type': 'e', 'parammaps': {
  610. pastureid: Cookies.get('pastureid'),
  611. bigid: '@insertRemainplan.LastInsertId',
  612. barid: '@insertSpotList2.id',
  613. bar: '@insertSpotList2.bname',
  614. type: 1
  615. }}
  616. ExecDataByConfig(this.requestParam).then(response => {
  617. console.log('新增保存发送参数', this.requestParam)
  618. if (response.msg === 'fail') {
  619. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  620. } else {
  621. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  622. this.getList()
  623. this.dropState = false
  624. }
  625. })
  626. },
  627. createCancel(row) {
  628. console.log('点击了新增取消')
  629. this.dropState = false
  630. for (let i = 0; i < this.table.list.length; i++) {
  631. if (row.myId === this.table.list[i].myId) {
  632. var listIndex = this.table.list.indexOf(this.table.list[i])
  633. }
  634. if (listIndex > -1) {
  635. this.table.list.splice(listIndex, 1)
  636. return
  637. }
  638. }
  639. },
  640. // 模板编辑
  641. handleUpdate(row) {
  642. for (let i = 0; i < this.table.list.length; i++) {
  643. if (this.table.list[i].Edit == true) {
  644. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  645. return false
  646. }
  647. }
  648. console.log(row, '=========')
  649. // 编辑true,不可编辑false
  650. row.Edit = true
  651. row.NoEdit = false
  652. // 新增false,编辑false,编辑保存true
  653. row.isCreate = false
  654. row.isUpdate = false
  655. row.isUpdateSave = true
  656. row.temp = {}
  657. row.temp2 = {}
  658. if (row.useinbarid == '0') { row.useinbarid = [] }
  659. if (row.barid == undefined) { row.barid = [] }
  660. if (row.tmrid == undefined) { row.tmrid = '' }
  661. if (row.times == undefined) { row.times = '' }
  662. if (row.treatmethod == undefined) { row.treatmethod = '' }
  663. // this.getCarFollowParm.parammaps.times = row.times
  664. if (row.times == '第一班') {
  665. this.getCarFollowParm.parammaps.times = 1
  666. row.times = '1'
  667. } else if (row.times == '第二班') {
  668. this.getCarFollowParm.parammaps.times = 2
  669. row.times = '2'
  670. } else if (row.times == '第三班') {
  671. this.getCarFollowParm.parammaps.times = 3
  672. row.times = '3'
  673. } else if (row.times == '第四班') {
  674. this.getCarFollowParm.parammaps.times = 4
  675. row.times = '4'
  676. } else if (row.times == '第五班') {
  677. this.getCarFollowParm.parammaps.times = 5
  678. row.times = '5'
  679. }
  680. GetDataByName(this.getCarFollowParm).then(response => {
  681. console.log('撒料计划车次跟随列表数据', response.data.list)
  682. if (response.data.list !== null) {
  683. this.carFollowList = response.data.list
  684. }
  685. })
  686. if (row.lppcode == undefined) {
  687. row.lppid = ''
  688. }
  689. this.getTransferbarsList()
  690. // row.barid = row.qstrids.split(',')
  691. // row.useinbarid = row.hstrids.split(',')
  692. var arr3 = []
  693. for (let i = 0; i < row.barid.length; i++) {
  694. arr3.push(this.barsList.find(obj => obj.id == row.barid[i]))
  695. }
  696. this.barsNamesIdTempArr = arr3
  697. var arr4 = []
  698. setTimeout(() => {
  699. for (let i = 0; i < row.useinbarid.length; i++) {
  700. arr4.push(this.transferbarsList.find(obj => obj.id == row.useinbarid[i]))
  701. }
  702. }, 500)
  703. this.useinbarNamesIdTempArr = arr4
  704. console.log(this.useinbarNamesIdTempArr, 'this.useinbarNamesIdTempArr')
  705. this.dropState = true
  706. },
  707. updateData(row) {
  708. console.log('点击了编辑保存', row)
  709. console.log(this.useinbarNamesIdTempArr, 'this.useinbarNamesIdTempArr========')
  710. if (row.rtime == null || row.rtime == 'null') {
  711. row.rtime = ''
  712. }
  713. if (row.barid == '' && row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  714. this.$message({ type: 'error', message: '栏舍/TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  715. return false
  716. } else if (row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  717. this.$message({ type: 'error', message: 'TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  718. return false
  719. } else if (row.times == '' && row.treatmethod == '') {
  720. this.$message({ type: 'error', message: '班次/混剩料处理方式不能为空', duration: 2000 })
  721. return false
  722. } else if (row.barid == '') {
  723. this.$message({ type: 'error', message: '栏舍不能为空', duration: 2000 })
  724. return false
  725. } else if (row.tmrid == '') {
  726. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  727. return false
  728. } else if (row.times == '') {
  729. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  730. return false
  731. } else if (row.treatmethod == '') {
  732. this.$message({ type: 'error', message: '剩料处理方式不能为空', duration: 2000 })
  733. return false
  734. }
  735. if (row.treatmethod !== '' && row.treatmethod == '转投剩料') {
  736. if (row.useinbarid == '') {
  737. this.$message({ type: 'error', message: '转投栏舍不能为空', duration: 2000 })
  738. return false
  739. }
  740. }
  741. if (row.treatmethod !== '' && row.treatmethod == '继续饲喂') {
  742. row.useinbarid = '0'
  743. }
  744. if (row.rtime == '' || row.rtime == null) {
  745. row.rtime = ''
  746. }
  747. for (let i = 0; i < this.table.list.length; i++) {
  748. if (row.sort == this.table.list[i].sort) {
  749. if (row.id !== this.table.list[i].id) {
  750. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  751. return false
  752. }
  753. }
  754. }
  755. var isInteger = /^\d+$/
  756. if (row.sort !== '') {
  757. if (!isInteger.test(parseFloat(row.sort))) {
  758. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  759. return false
  760. }
  761. }
  762. if (row.sort == '' || row.sort == 0) {
  763. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  764. return false
  765. }
  766. if (row.times == '第一班') {
  767. row.times = 1
  768. } else if (row.times == '第二班') {
  769. row.times = 2
  770. } else if (row.times == '第三班') {
  771. row.times = 3
  772. } else if (row.times == '第四班') {
  773. row.times = 4
  774. } else if (row.times == '第五班') {
  775. row.times = 5
  776. }
  777. this.isokDisable = true
  778. setTimeout(() => {
  779. this.isokDisable = false
  780. }, 1000)
  781. this.requestParam = {}
  782. this.requestParam.common = { 'returnmap': '0' }
  783. this.requestParam.data = []
  784. this.requestParam.data[0] = { 'name': 'updateRemainplan', 'type': 'e', 'parammaps': {
  785. pastureid: row.pastureid,
  786. id: row.id,
  787. sort: row.sort,
  788. tmrid: row.tmrid,
  789. tmrcode: row.tmrcode,
  790. enable: row.enable,
  791. times: row.times,
  792. lppid: row.lppid,
  793. lppcode: row.lppcode,
  794. rtime: row.rtime,
  795. treatmethod: row.treatmethod
  796. }}
  797. this.requestParam.data[1] = { 'name': 'deleteRpdetail', 'type': 'e', 'parammaps': {
  798. pastureid: row.pastureid,
  799. bigid: row.id
  800. }}
  801. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.barsNamesIdTempArr }}
  802. this.requestParam.data[2].children = []
  803. this.requestParam.data[2].children[0] = { 'name': 'insertRpdetail', 'type': 'e', 'parammaps': {
  804. pastureid: row.pastureid,
  805. bigid: row.id,
  806. barid: '@insertSpotList2.id',
  807. bar: '@insertSpotList2.bname',
  808. type: 0
  809. }}
  810. this.requestParam.data[3] = { 'name': 'insertSpotList3', 'resultmaps': { 'list': this.useinbarNamesIdTempArr }}
  811. this.requestParam.data[3].children = []
  812. this.requestParam.data[3].children[0] = { 'name': 'insertRpdetail', 'type': 'e', 'parammaps': {
  813. pastureid: row.pastureid,
  814. bigid: row.id,
  815. barid: '@insertSpotList3.id',
  816. bar: '@insertSpotList3.bname',
  817. type: 1
  818. }}
  819. ExecDataByConfig(this.requestParam).then(response => {
  820. console.log('新增保存发送参数', this.requestParam)
  821. if (response.msg === 'fail') {
  822. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  823. } else {
  824. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  825. this.getList()
  826. this.dropState = false
  827. }
  828. })
  829. // this.requestParam.name = 'updateRemainplan'
  830. // this.requestParam.parammaps = row
  831. // this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  832. // PostDataByName(this.requestParam).then(response => {
  833. // console.log('新增保存发送参数', this.requestParam)
  834. // if (response.msg !== 'fail') {
  835. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  836. // this.getList()
  837. // this.dropState = false
  838. // } else {
  839. // this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  840. // }
  841. // })
  842. },
  843. updateCancel(row) {
  844. console.log('点击了编辑取消')
  845. // 编辑false,不可编辑true
  846. row.Edit = false
  847. row.NoEdit = true
  848. // 新增false,编辑true,编辑保存false
  849. row.isCreate = false
  850. row.isUpdate = true
  851. row.isUpdateSave = false
  852. this.getList()
  853. this.dropState = false
  854. },
  855. handleSelect(val) {
  856. console.log('勾选数据', val)
  857. this.selectList = val
  858. },
  859. // 行内删除
  860. handleRowDelete(row) {
  861. console.log(row, '点击了行删除')
  862. MessageBox.confirm('是否确认删除此信息?', {
  863. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  864. }).then(() => {
  865. this.selectList = []
  866. this.requestParam = {}
  867. this.requestParam.name = 'deleteRemainplan'
  868. this.requestParam.parammaps = {}
  869. this.requestParam.parammaps.pastureid = row.pastureid
  870. this.requestParam.parammaps.id = row.id
  871. PostDataByName(this.requestParam).then(response => {
  872. if (response.msg === 'fail') {
  873. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  874. } else {
  875. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  876. this.getList()
  877. }
  878. })
  879. }).catch(() => {
  880. this.$message({ type: 'info', message: '已取消删除' })
  881. })
  882. },
  883. // 减少车次
  884. handleDelete() {
  885. if (this.selectList.length == 0) {
  886. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  887. } else {
  888. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  889. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  890. }).then(() => {
  891. console.log(this.selectList)
  892. this.requestParam.common = { 'returnmap': '0' }
  893. this.requestParam.data = []
  894. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  895. this.requestParam.data[0].children = []
  896. this.requestParam.data[0].children[0] = { 'name': 'deleteRemainplan', 'type': 'e', 'parammaps': {
  897. id: '@insertSpotList.id',
  898. pastureid: '@insertSpotList.pastureid'
  899. }}
  900. ExecDataByConfig(this.requestParam).then(response => {
  901. console.log('删除保存发送参数', this.requestParam)
  902. if (response.msg === 'fail') {
  903. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  904. } else {
  905. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  906. this.getList()
  907. }
  908. })
  909. })
  910. }
  911. },
  912. // 校验
  913. handleCheck() {
  914. console.log('点击了校验')
  915. this.check.dialogStatus = 'check'
  916. this.check.dialogFormVisible = true
  917. this.getCheckList()
  918. },
  919. getCheckList() {
  920. GetDataByName(this.check.getCheckParm).then(response => {
  921. if (response.data.list[0].bnames !== undefined) {
  922. this.check.temp.isDistribution = 0
  923. this.check.temp.bnames = response.data.list[0].bnames
  924. } else {
  925. this.check.temp = {}
  926. this.check.temp.isDistribution = 1
  927. }
  928. })
  929. },
  930. // 历史记录
  931. handleHistoryRecords() {
  932. console.log('点击了历史记录')
  933. this.history.dialogStatus = 'history'
  934. this.history.dialogFormVisible = true
  935. this.getDateList()
  936. },
  937. // 历史时间
  938. getDateList() {
  939. GetDataByName(this.history.getdataDateParm).then(response => {
  940. console.log('table数据', response.data.list)
  941. if (response.data.list !== null) {
  942. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  943. this.getHistoryList()
  944. } else {
  945. this.history.getdataListParm.parammaps.date = ''
  946. }
  947. })
  948. },
  949. changeDate() {
  950. this.getHistoryList()
  951. },
  952. // 应用
  953. handleApplication() {
  954. console.log('点击了应用')
  955. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  956. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  957. }).then(() => {
  958. this.requestParam.name = 'applyFPdate'
  959. this.requestParam.parammaps = {}
  960. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  961. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  962. PostDataByName(this.requestParam).then(response => {
  963. if (response.msg === 'fail') {
  964. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  965. } else {
  966. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  967. this.getHistoryIsDisplay()
  968. this.getList()
  969. }
  970. })
  971. }).catch(() => {
  972. this.$message({ type: 'info', message: '已取消应用' })
  973. })
  974. },
  975. getHistoryList() {
  976. this.history.listLoading = true
  977. GetDataByName(this.history.getdataListParm).then(response => {
  978. console.log('table数据', response.data.list)
  979. if (response.data.list !== null) {
  980. console.log('table数据', response.data.list)
  981. this.history.list = response.data.list
  982. this.history.pageNum = response.data.pageNum
  983. this.history.pageSize = response.data.pageSize
  984. this.history.total = response.data.total
  985. } else {
  986. this.history.list = []
  987. }
  988. setTimeout(() => {
  989. this.history.listLoading = false
  990. }, 100)
  991. })
  992. }
  993. }
  994. }
  995. </script>
  996. <style lang="scss" scoped>
  997. .search{clear: both;}
  998. .table{margin-top:10px;}
  999. </style>