d0d075c6eb73e8601003c4c6535c65b3387854f9.svn-base 40 KB

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