8951640148af39fff49ed8440bd03c217727d2f7.svn-base 41 KB

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