690ad5ce6d0178f3cbf2524d5b89411309ec92c3.svn-base 40 KB

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