7bc0659e7c21463a4a98d8d614c7b766ebb5a077.svn-base 42 KB

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