c5fa413ffcb8a1e4fd875e78b0dc0b3586db020b.svn-base 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  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.useinbar }}</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. }, 1000)
  693. this.useinbarNamesIdTempArr = arr4
  694. this.dropState = true
  695. },
  696. updateData(row) {
  697. console.log('点击了编辑保存', row)
  698. if (row.rtime == null || row.rtime == 'null') {
  699. row.rtime = ''
  700. }
  701. if (row.barid == '' && row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  702. this.$message({ type: 'error', message: '栏舍/TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  703. return false
  704. } else if (row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  705. this.$message({ type: 'error', message: 'TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  706. return false
  707. } else if (row.times == '' && row.treatmethod == '') {
  708. this.$message({ type: 'error', message: '班次/混剩料处理方式不能为空', duration: 2000 })
  709. return false
  710. } else if (row.barid == '') {
  711. this.$message({ type: 'error', message: '栏舍不能为空', duration: 2000 })
  712. return false
  713. } else if (row.tmrid == '') {
  714. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  715. return false
  716. } else if (row.times == '') {
  717. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  718. return false
  719. } else if (row.treatmethod == '') {
  720. this.$message({ type: 'error', message: '剩料处理方式不能为空', duration: 2000 })
  721. return false
  722. }
  723. if (row.treatmethod !== '' && row.treatmethod == '转投剩料') {
  724. if (row.useinbarid == '') {
  725. this.$message({ type: 'error', message: '转投栏舍不能为空', duration: 2000 })
  726. return false
  727. }
  728. }
  729. if (row.treatmethod !== '' && row.treatmethod == '继续饲喂') {
  730. row.useinbarid = '0'
  731. }
  732. if (row.rtime == '' || row.rtime == null) {
  733. row.rtime = ''
  734. }
  735. for (let i = 0; i < this.table.list.length; i++) {
  736. if (row.sort == this.table.list[i].sort) {
  737. if (row.id !== this.table.list[i].id) {
  738. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  739. return false
  740. }
  741. }
  742. }
  743. var isInteger = /^\d+$/
  744. if (row.sort !== '') {
  745. if (!isInteger.test(parseFloat(row.sort))) {
  746. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  747. return false
  748. }
  749. }
  750. if (row.sort == '' || row.sort == 0) {
  751. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  752. return false
  753. }
  754. if (row.times == '第一班') {
  755. row.times = 1
  756. } else if (row.times == '第二班') {
  757. row.times = 2
  758. } else if (row.times == '第三班') {
  759. row.times = 3
  760. } else if (row.times == '第四班') {
  761. row.times = 4
  762. } else if (row.times == '第五班') {
  763. row.times = 5
  764. }
  765. this.isokDisable = true
  766. setTimeout(() => {
  767. this.isokDisable = false
  768. }, 1000)
  769. this.requestParam = {}
  770. this.requestParam.common = { 'returnmap': '0' }
  771. this.requestParam.data = []
  772. this.requestParam.data[0] = { 'name': 'updateRemainplan', 'type': 'e', 'parammaps': {
  773. pastureid: row.pastureid,
  774. id: row.id,
  775. sort: row.sort,
  776. tmrid: row.tmrid,
  777. tmrcode: row.tmrcode,
  778. enable: row.enable,
  779. times: row.times,
  780. lppid: row.lppid,
  781. lppcode: row.lppcode,
  782. rtime: row.rtime,
  783. treatmethod: row.treatmethod
  784. }}
  785. this.requestParam.data[1] = { 'name': 'deleteRpdetail', 'type': 'e', 'parammaps': {
  786. pastureid: row.pastureid,
  787. bigid: row.id
  788. }}
  789. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.barsNamesIdTempArr }}
  790. this.requestParam.data[2].children = []
  791. this.requestParam.data[2].children[0] = { 'name': 'insertRpdetail', 'type': 'e', 'parammaps': {
  792. pastureid: row.pastureid,
  793. bigid: row.id,
  794. barid: '@insertSpotList.id',
  795. bar: '@insertSpotList.bname',
  796. type: 0
  797. }}
  798. this.requestParam.data[3] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.useinbarNamesIdTempArr }}
  799. this.requestParam.data[3].children = []
  800. this.requestParam.data[3].children[0] = { 'name': 'insertRpdetail', 'type': 'e', 'parammaps': {
  801. pastureid: row.pastureid,
  802. bigid: row.id,
  803. barid: '@insertSpotList.id',
  804. bar: '@insertSpotList.bname',
  805. type: 1
  806. }}
  807. ExecDataByConfig(this.requestParam).then(response => {
  808. console.log('新增保存发送参数', this.requestParam)
  809. if (response.msg === 'fail') {
  810. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  811. } else {
  812. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  813. this.getList()
  814. this.dropState = false
  815. }
  816. })
  817. // this.requestParam.name = 'updateRemainplan'
  818. // this.requestParam.parammaps = row
  819. // this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  820. // PostDataByName(this.requestParam).then(response => {
  821. // console.log('新增保存发送参数', this.requestParam)
  822. // if (response.msg !== 'fail') {
  823. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  824. // this.getList()
  825. // this.dropState = false
  826. // } else {
  827. // this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  828. // }
  829. // })
  830. },
  831. updateCancel(row) {
  832. console.log('点击了编辑取消')
  833. // 编辑false,不可编辑true
  834. row.Edit = false
  835. row.NoEdit = true
  836. // 新增false,编辑true,编辑保存false
  837. row.isCreate = false
  838. row.isUpdate = true
  839. row.isUpdateSave = false
  840. this.getList()
  841. this.dropState = false
  842. },
  843. handleSelect(val) {
  844. console.log('勾选数据', val)
  845. this.selectList = val
  846. },
  847. // 行内删除
  848. handleRowDelete(row) {
  849. console.log(row, '点击了行删除')
  850. MessageBox.confirm('是否确认删除此信息?', {
  851. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  852. }).then(() => {
  853. this.selectList = []
  854. this.requestParam = {}
  855. this.requestParam.name = 'deleteRemainplan'
  856. this.requestParam.parammaps = {}
  857. this.requestParam.parammaps.pastureid = row.pastureid
  858. this.requestParam.parammaps.id = row.id
  859. PostDataByName(this.requestParam).then(response => {
  860. if (response.msg === 'fail') {
  861. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  862. } else {
  863. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  864. this.getList()
  865. }
  866. })
  867. }).catch(() => {
  868. this.$message({ type: 'info', message: '已取消删除' })
  869. })
  870. },
  871. // 减少车次
  872. handleDelete() {
  873. if (this.selectList.length == 0) {
  874. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  875. } else {
  876. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  877. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  878. }).then(() => {
  879. console.log(this.selectList)
  880. this.requestParam.common = { 'returnmap': '0' }
  881. this.requestParam.data = []
  882. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  883. this.requestParam.data[0].children = []
  884. this.requestParam.data[0].children[0] = { 'name': 'deleteRemainplan', 'type': 'e', 'parammaps': {
  885. id: '@insertSpotList.id',
  886. pastureid: '@insertSpotList.pastureid'
  887. }}
  888. ExecDataByConfig(this.requestParam).then(response => {
  889. console.log('删除保存发送参数', this.requestParam)
  890. if (response.msg === 'fail') {
  891. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  892. } else {
  893. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  894. this.getList()
  895. }
  896. })
  897. })
  898. }
  899. },
  900. // 校验
  901. handleCheck() {
  902. console.log('点击了校验')
  903. this.check.dialogStatus = 'check'
  904. this.check.dialogFormVisible = true
  905. this.getCheckList()
  906. },
  907. getCheckList() {
  908. GetDataByName(this.check.getCheckParm).then(response => {
  909. if (response.data.list[0].bnames !== undefined) {
  910. this.check.temp.isDistribution = 0
  911. this.check.temp.bnames = response.data.list[0].bnames
  912. } else {
  913. this.check.temp = {}
  914. this.check.temp.isDistribution = 1
  915. }
  916. })
  917. },
  918. // 历史记录
  919. handleHistoryRecords() {
  920. console.log('点击了历史记录')
  921. this.history.dialogStatus = 'history'
  922. this.history.dialogFormVisible = true
  923. this.getDateList()
  924. },
  925. // 历史时间
  926. getDateList() {
  927. GetDataByName(this.history.getdataDateParm).then(response => {
  928. console.log('table数据', response.data.list)
  929. if (response.data.list !== null) {
  930. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  931. this.getHistoryList()
  932. } else {
  933. this.history.getdataListParm.parammaps.date = ''
  934. }
  935. })
  936. },
  937. changeDate() {
  938. this.getHistoryList()
  939. },
  940. // 应用
  941. handleApplication() {
  942. console.log('点击了应用')
  943. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  944. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  945. }).then(() => {
  946. this.requestParam.name = 'applyFPdate'
  947. this.requestParam.parammaps = {}
  948. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  949. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  950. PostDataByName(this.requestParam).then(response => {
  951. if (response.msg === 'fail') {
  952. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  953. } else {
  954. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  955. this.getHistoryIsDisplay()
  956. this.getList()
  957. }
  958. })
  959. }).catch(() => {
  960. this.$message({ type: 'info', message: '已取消应用' })
  961. })
  962. },
  963. getHistoryList() {
  964. this.history.listLoading = true
  965. GetDataByName(this.history.getdataListParm).then(response => {
  966. console.log('table数据', response.data.list)
  967. if (response.data.list !== null) {
  968. console.log('table数据', response.data.list)
  969. this.history.list = response.data.list
  970. this.history.pageNum = response.data.pageNum
  971. this.history.pageSize = response.data.pageSize
  972. this.history.total = response.data.total
  973. } else {
  974. this.history.list = []
  975. }
  976. setTimeout(() => {
  977. this.history.listLoading = false
  978. }, 100)
  979. })
  980. }
  981. }
  982. }
  983. </script>
  984. <style lang="scss" scoped>
  985. .search{clear: both;}
  986. .table{margin-top:10px;}
  987. </style>