66a4b035331d19c0410de1b3d975829bfdb70ae8.svn-base 42 KB

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