4cdf4fae5363d33bf7720c41dcd21891055463ae.svn-base 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  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="import" style="float: right;" @click="handleHistoryRecords">历史记录</el-button>
  7. </div>
  8. <div class="search" />
  9. <div class="table">
  10. <el-table
  11. id="table"
  12. :key="table.tableKey"
  13. v-loading="table.listLoading"
  14. element-loading-text="给我一点时间"
  15. :data="table.list"
  16. border
  17. fit
  18. highlight-current-row
  19. style="width: 100%;"
  20. :row-style="rowStyle"
  21. :cell-style="cellStyle"
  22. class="elTable table-fixed"
  23. row-key="id"
  24. @selection-change="handleSelect"
  25. >
  26. <el-table-column type="selection" min-width="50" />
  27. <el-table-column label="车次" min-width="130px" align="center">
  28. <template slot-scope="scope">
  29. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  30. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" type="number" style="width:95%;padding:10px 0;" />
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="栏舍" min-width="130px" align="center">
  34. <template slot-scope="scope">
  35. <span v-if="scope.row.NoEdit">{{ scope.row.bar }}</span>
  36. <el-select v-if="scope.row.Edit" v-model="scope.row.barid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeBars(value, scope.row)}">
  37. <el-option v-for="item in barsList" :key="item.id" :label="item.bname" :value="item.id" />
  38. </el-select>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="TMR编号" prop="weight" min-width="130px" align="center">
  42. <template slot-scope="scope">
  43. <span v-if="scope.row.NoEdit">{{ scope.row.tmrcode }}</span>
  44. <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)}">
  45. <el-option v-for="item in TMRNumberList" :key="item.id" :label="item.tname" :value="item.id" />
  46. </el-select>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="生效" min-width="130px" align="center">
  50. <template slot-scope="scope">
  51. <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)" />
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="班次" min-width="130px" align="center">
  55. <template slot-scope="scope">
  56. <span v-if="scope.row.NoEdit">{{ scope.row.times }}</span>
  57. <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)}">
  58. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  59. </el-select>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="发料计划车次跟随" min-width="130px" align="center">
  63. <template slot-scope="scope">
  64. <span v-if="scope.row.NoEdit">{{ scope.row.lppcode }}</span>
  65. <el-select v-if="scope.row.Edit" v-model="scope.row.lppid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeCarFollow(value, scope.row)}">
  66. <el-option v-for="item in carFollowList" :key="item.id" :label="item.lppcode" :value="item.id" />
  67. </el-select>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="时间" min-width="180px" align="center">
  71. <template slot-scope="scope">
  72. <span v-if="scope.row.NoEdit">{{ scope.row.rtime }}</span>
  73. <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%;" />
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="剩料处理方式" min-width="130px" align="center">
  77. <template slot-scope="scope">
  78. <span v-if="scope.row.NoEdit">{{ scope.row.treatmethod }}</span>
  79. <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)}">
  80. <el-option v-for="item in residueDisposalList" :key="item.value" :label="item.label" :value="item.label" />
  81. </el-select>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="转投栏舍" min-width="130px" align="center">
  85. <template slot-scope="scope">
  86. <span v-if="scope.row.NoEdit">{{ scope.row.useinbar }}</span>
  87. <el-select v-if="scope.row.Edit" v-model="scope.row.useinbarid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeTransferbars(value, scope.row)}">
  88. <el-option v-for="item in transferbarsList" :key="item.id" :label="item.bname" :value="item.id" />
  89. </el-select>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  93. <template slot-scope="{row}">
  94. <!-- 新增 -->
  95. <el-button v-if="row.isCreate" class="miniSuccess" :disabled="isokDisable" @click="createData(row)">保存</el-button>
  96. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  97. <!-- 编辑 -->
  98. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  99. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  100. <!-- 编辑保存 -->
  101. <el-button v-if="row.isUpdateSave" class="miniSuccess" :disabled="isokDisable" @click="updateData(row)">保存</el-button>
  102. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. </div>
  107. <!-- 历史记录 -->
  108. <el-dialog :title="textMap[history.dialogStatus]" :destroy-on-close="true" :visible.sync="history.dialogFormVisible" :close-on-click-modal="false" width="90%">
  109. <div class="app-history">
  110. <div class="search">
  111. <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" />
  112. <el-button class="successBorder" @click="handleApplication">应用</el-button>
  113. </div>
  114. <div class="table">
  115. <el-table
  116. :key="history.tableKey"
  117. v-loading="history.listLoading"
  118. element-loading-text="给我一点时间"
  119. :data="history.list"
  120. border
  121. fit
  122. highlight-current-row
  123. style="width: 100%;"
  124. :row-style="rowStyle"
  125. :cell-style="cellStyle"
  126. class="elTable table-fixed"
  127. >
  128. <el-table-column label="车次" min-width="130px" align="center">
  129. <template slot-scope="scope">
  130. <span>{{ scope.row.sort }}</span>
  131. </template>
  132. </el-table-column>
  133. <el-table-column label="栏舍" min-width="130px" align="center">
  134. <template slot-scope="scope">
  135. <span>{{ scope.row.bar }}</span>
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="TMR编号" prop="weight" min-width="130px" align="center">
  139. <template slot-scope="scope">
  140. <span>{{ scope.row.tmrcode }}</span>
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="生效" min-width="130px" align="center">
  144. <template slot-scope="scope">
  145. <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)" />
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="班次" min-width="130px" align="center">
  149. <template slot-scope="scope">
  150. <span>{{ scope.row.times }}</span>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="发料计划车次跟随" min-width="130px" align="center">
  154. <template slot-scope="scope">
  155. <span>{{ scope.row.lppcode }}</span>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="时间" min-width="180px" align="center">
  159. <template slot-scope="scope">
  160. <span>{{ scope.row.rtime }}</span>
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="剩料处理方式" min-width="130px" align="center">
  164. <template slot-scope="scope">
  165. <span>{{ scope.row.treatmethod }}</span>
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="转投栏舍" min-width="130px" align="center">
  169. <template slot-scope="scope">
  170. <span>{{ scope.row.useinbar }}</span>
  171. </template>
  172. </el-table-column>
  173. </el-table>
  174. <pagination v-show="history.total>0" :total="history.total" :page.sync="history.getdataListParm.offset" :limit.sync="history.getdataListParm.pagecount" @pagination="getHistoryList" />
  175. </div>
  176. </div>
  177. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  178. <el-button class="cancel" @click="history.dialogFormVisible = false; ">关闭</el-button>
  179. </div>
  180. </el-dialog>
  181. </div>
  182. </template>
  183. <script>
  184. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  185. import Pagination from '@/components/Pagination'
  186. import Sortable from 'sortablejs'
  187. import Cookies from 'js-cookie'
  188. import { MessageBox } from 'element-ui'
  189. export default {
  190. name: 'SurplusMaterialPlan',
  191. components: { Pagination },
  192. data() {
  193. return {
  194. requestParams: [
  195. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  196. { name: 'getTMRYHList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  197. ],
  198. barsList: [], // 栏舍
  199. residueDisposalList: [{ value: '0', label: '转投剩料' }, { value: '1', label: '继续饲喂' }], // 剩料处理方式
  200. TMRNumberList: [], // TMR编号
  201. // 班次
  202. maxTime: {
  203. getMaxTimesParm: {
  204. name: 'getSysoptEnable',
  205. page: 1,
  206. offset: 1,
  207. pagecount: 1,
  208. returntype: 'Map',
  209. parammaps: {
  210. pastureid: Cookies.get('pastureid'),
  211. inforname: 'times'
  212. }
  213. }
  214. },
  215. frequencyList: [], // 班次
  216. getCarFollowParm: {
  217. name: 'getLPPCodeList',
  218. offset: 0,
  219. pagecount: 0,
  220. parammaps: {
  221. pastureid: Cookies.get('pastureid'),
  222. times: ''
  223. }
  224. },
  225. carFollowList: [], // 发料计划车次跟随
  226. getTransferbarsParm: {
  227. name: 'getBarListEnable',
  228. offset: 0,
  229. pagecount: 0,
  230. parammaps: {
  231. pastureid: Cookies.get('pastureid'),
  232. times: ''
  233. }
  234. },
  235. transferbarsList: [], // 转头栏舍
  236. table: {
  237. getdataListParm: {
  238. name: 'getRemainplanList',
  239. page: 1,
  240. offset: 1,
  241. pagecount: 10,
  242. returntype: 'Map',
  243. parammaps: {
  244. pastureid: Cookies.get('pastureid')
  245. }
  246. },
  247. tableKey: 0,
  248. list: [],
  249. total: 0,
  250. listLoading: true
  251. },
  252. history: {
  253. dialogFormVisible: false,
  254. dialogStatus: '',
  255. temp: {},
  256. rules: {},
  257. tableKey: 0,
  258. list: [],
  259. total: 0,
  260. listLoading: true,
  261. getdataDateParm: {
  262. name: 'getRPMaxDate',
  263. page: 1,
  264. offset: 1,
  265. pagecount: 10,
  266. returntype: 'Map',
  267. parammaps: {
  268. pastureid: Cookies.get('pastureid')
  269. }
  270. },
  271. getdataListParm: {
  272. name: 'getRemainplanListDate',
  273. page: 1,
  274. offset: 1,
  275. pagecount: 10,
  276. returntype: 'Map',
  277. parammaps: {
  278. pastureid: Cookies.get('pastureid'),
  279. date: ''
  280. }
  281. }
  282. },
  283. textMap: {
  284. history: '历史记录'
  285. },
  286. requestParam: {},
  287. selectList: [],
  288. isokDisable: false,
  289. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  290. cellStyle: { padding: 0 + 'px' },
  291. dropState: false
  292. }
  293. },
  294. created() {
  295. this.getList()
  296. this.getDownList()
  297. this.getIsDisplay()
  298. },
  299. methods: {
  300. getDownList() {
  301. GetDataByNames(this.requestParams).then(response => {
  302. this.barsList = response.data.getBarListEnable.list
  303. this.TMRNumberList = response.data.getTMRYHList.list
  304. })
  305. },
  306. getIsDisplay() {
  307. GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
  308. if (response.data.list[0].inforvalue == 1) {
  309. this.frequencyList = [{ id: '1', name: '第一班' }]
  310. } else if (response.data.list[0].inforvalue == 2) {
  311. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
  312. } else if (response.data.list[0].inforvalue == 3) {
  313. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  314. } else if (response.data.list[0].inforvalue == 4) {
  315. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  316. }
  317. })
  318. },
  319. getList() {
  320. this.table.listLoading = true
  321. GetDataByName(this.table.getdataListParm).then(response => {
  322. console.log('table数据', response.data.list)
  323. if (response.data.list !== null) {
  324. for (let i = 0; i < response.data.list.length; i++) {
  325. this.$set(response.data.list[i], 'Edit', false) // 编辑
  326. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  327. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  328. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  329. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  330. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  331. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  332. }
  333. this.table.list = response.data.list
  334. this.table.pageNum = response.data.pageNum
  335. this.table.pageSize = response.data.pageSize
  336. this.rowDrop()
  337. this.table.total = response.data.total
  338. } else {
  339. this.table.list = []
  340. }
  341. setTimeout(() => {
  342. this.table.listLoading = false
  343. }, 100)
  344. })
  345. },
  346. handleEnableChange() {
  347. console.log('点击了生效')
  348. },
  349. // 行拖拽
  350. rowDrop() {
  351. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  352. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  353. const that = this
  354. var sortable = Sortable.create(tbody, {
  355. disabled: that.dropState,
  356. onChoose({ newIndex, oldIndex }) {
  357. if (that.dropState == true) {
  358. sortable.destroy()
  359. }
  360. },
  361. onEnd({ newIndex, oldIndex }) {
  362. const currRow = that.table.list.splice(oldIndex, 1)[0]
  363. that.table.list.splice(newIndex, 0, currRow)
  364. console.log('索引', newIndex)
  365. console.log('拖动数据', currRow)
  366. console.log('上', that.table.list[newIndex - 1])
  367. console.log('下', that.table.list[newIndex + 1])
  368. }
  369. })
  370. },
  371. // 模板新增
  372. handleCreate() {
  373. console.log('点击了新增车次')
  374. // 编辑true/不可编辑false
  375. // 新增操true,编辑false,编辑保存false
  376. this.dropState = true
  377. for (let i = 0; i < this.table.list.length; i++) {
  378. if (this.table.list[i].Edit === true) {
  379. console.log(123)
  380. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  381. return false
  382. }
  383. }
  384. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'sort': parseInt(this.table.list[this.table.list.length - 1].sort) + 1, 'ftid': '', 'ftname': '', 'tmrcode': '', 'tmrid': '', 'times': '', 'lppcode': '', 'lppid': '', 'rtime': '', 'treatmethod': '', 'useinbar': '', 'useinbarid': '' })
  385. },
  386. // 栏舍
  387. changeBars(item, row) {
  388. row.bar = this.barsList.find(obj => obj.id == item).bname
  389. },
  390. // TMR编号
  391. changeTMRNumber(item, row) {
  392. row.tmrcode = this.TMRNumberList.find(obj => obj.id == item).tname
  393. },
  394. // 撒料计划车次跟随列表
  395. changeCarFollow(item, row) {
  396. row.lppcode = this.carFollowList.find(obj => obj.id == item).lppcode
  397. },
  398. // 班次
  399. changeTimes(item, row) {
  400. console.log(item, row)
  401. this.getCarFollowParm.parammaps.times = item
  402. this.getCarFollowList(row)
  403. },
  404. // 撒料计划车次跟随列表
  405. getCarFollowList(row) {
  406. GetDataByName(this.getCarFollowParm).then(response => {
  407. console.log('撒料计划车次跟随列表数据', response.data.list)
  408. if (response.data.list !== null) {
  409. this.carFollowList = response.data.list
  410. row.lppid = this.carFollowList[0].id
  411. row.lppcode = this.carFollowList[0].lppcode
  412. }
  413. })
  414. },
  415. changeResidueDisposal(item, row) {
  416. console.log(item, row)
  417. this.getCarFollowParm.parammaps.times = item
  418. this.getTransferbarsList()
  419. },
  420. getTransferbarsList() {
  421. GetDataByName(this.getTransferbarsParm).then(response => {
  422. console.log('撒料计划车次跟随列表数据', response.data.list)
  423. if (response.data.list !== null) {
  424. this.transferbarsList = response.data.list
  425. }
  426. })
  427. },
  428. // 转头栏舍
  429. changeTransferbars(item, row) {
  430. console.log(item, row)
  431. row.useinbar = this.transferbarsList.find(obj => obj.id == item).bname
  432. },
  433. createData(row) {
  434. console.log('点击了新增保存', row)
  435. if (row.barid == '' && row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  436. this.$message({ type: 'error', message: '栏舍/TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  437. return false
  438. } else if (row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  439. this.$message({ type: 'error', message: 'TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  440. return false
  441. } else if (row.times == '' && row.treatmethod == '') {
  442. this.$message({ type: 'error', message: '班次/混剩料处理方式不能为空', duration: 2000 })
  443. return false
  444. } else if (row.barid == '') {
  445. this.$message({ type: 'error', message: '栏舍不能为空', duration: 2000 })
  446. return false
  447. } else if (row.tmrid == '') {
  448. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  449. return false
  450. } else if (row.times == '') {
  451. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  452. return false
  453. } else if (row.treatmethod == '') {
  454. this.$message({ type: 'error', message: '剩料处理方式不能为空', duration: 2000 })
  455. return false
  456. }
  457. if (row.treatmethod !== '' && row.treatmethod == '转投剩料') {
  458. if (row.useinbarid == '') {
  459. this.$message({ type: 'error', message: '转投栏舍不能为空', duration: 2000 })
  460. return false
  461. }
  462. }
  463. if (row.treatmethod !== '' && row.treatmethod == '继续饲喂') {
  464. row.useinbarid = '0'
  465. }
  466. if (row.rtime == '' || row.rtime == null) {
  467. row.rtime = ''
  468. }
  469. for (let i = 0; i < this.table.list.length; i++) {
  470. if (row.sort == this.table.list[i].sort) {
  471. if (row.id !== this.table.list[i].id) {
  472. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  473. return false
  474. }
  475. }
  476. }
  477. var isInteger = /^\d+$/
  478. if (row.sort !== '') {
  479. if (!isInteger.test(parseFloat(row.sort))) {
  480. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  481. return false
  482. }
  483. }
  484. this.isokDisable = true
  485. setTimeout(() => {
  486. this.isokDisable = false
  487. }, 1000)
  488. this.requestParam.name = 'insertRemainplan'
  489. this.requestParam.parammaps = row
  490. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  491. PostDataByName(this.requestParam).then(response => {
  492. console.log('新增保存发送参数', this.requestParam)
  493. if (response.msg !== 'fail') {
  494. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  495. this.getList()
  496. this.dropState = false
  497. } else {
  498. failproccess(response, this.$notify)
  499. }
  500. })
  501. },
  502. createCancel(row) {
  503. console.log('点击了新增取消')
  504. this.dropState = false
  505. for (let i = 0; i < this.table.list.length; i++) {
  506. if (row.myId === this.table.list[i].myId) {
  507. var listIndex = this.table.list.indexOf(this.table.list[i])
  508. }
  509. if (listIndex > -1) {
  510. this.table.list.splice(listIndex, 1)
  511. return
  512. }
  513. }
  514. },
  515. // 模板编辑
  516. handleUpdate(row) {
  517. for (let i = 0; i < this.table.list.length; i++) {
  518. if (this.table.list[i].Edit == true) {
  519. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  520. return false
  521. }
  522. }
  523. // 编辑true,不可编辑false
  524. row.Edit = true
  525. row.NoEdit = false
  526. // 新增false,编辑false,编辑保存true
  527. row.isCreate = false
  528. row.isUpdate = false
  529. row.isUpdateSave = true
  530. if (row.useinbarid == '0') { row.useinbarid = '' }
  531. if (row.barid == undefined) { row.barid = '' }
  532. if (row.tmrid == undefined) { row.tmrid = '' }
  533. if (row.times == undefined) { row.times = '' }
  534. if (row.useinbarid == undefined) { row.useinbarid = '' }
  535. if (row.treatmethod == undefined) { row.treatmethod = '' }
  536. this.getCarFollowParm.parammaps.times = row.times
  537. this.getCarFollowList(row)
  538. this.dropState = true
  539. },
  540. updateData(row) {
  541. console.log('点击了编辑保存', row)
  542. 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.barid == '') {
  552. this.$message({ type: 'error', message: '栏舍不能为空', duration: 2000 })
  553. return false
  554. } else if (row.tmrid == '') {
  555. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  556. return false
  557. } else if (row.times == '') {
  558. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  559. return false
  560. } else if (row.treatmethod == '') {
  561. this.$message({ type: 'error', message: '剩料处理方式不能为空', duration: 2000 })
  562. return false
  563. }
  564. if (row.treatmethod !== '' && row.treatmethod == '转投剩料') {
  565. if (row.useinbarid == '') {
  566. this.$message({ type: 'error', message: '转投栏舍不能为空', duration: 2000 })
  567. return false
  568. }
  569. }
  570. if (row.treatmethod !== '' && row.treatmethod == '继续饲喂') {
  571. row.useinbarid = '0'
  572. }
  573. if (row.rtime == '' || row.rtime == null) {
  574. row.rtime = ''
  575. }
  576. for (let i = 0; i < this.table.list.length; i++) {
  577. if (row.sort == this.table.list[i].sort) {
  578. if (row.id !== this.table.list[i].id) {
  579. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  580. return false
  581. }
  582. }
  583. }
  584. var isInteger = /^\d+$/
  585. if (row.sort !== '') {
  586. if (!isInteger.test(parseFloat(row.sort))) {
  587. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  588. return false
  589. }
  590. }
  591. this.isokDisable = true
  592. setTimeout(() => {
  593. this.isokDisable = false
  594. }, 1000)
  595. this.requestParam.name = 'updateRemainplan'
  596. this.requestParam.parammaps = row
  597. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  598. PostDataByName(this.requestParam).then(response => {
  599. console.log('新增保存发送参数', this.requestParam)
  600. if (response.msg !== 'fail') {
  601. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  602. this.getList()
  603. this.dropState = false
  604. } else {
  605. failproccess(response, this.$notify)
  606. }
  607. })
  608. },
  609. updateCancel(row) {
  610. console.log('点击了编辑取消')
  611. // 编辑false,不可编辑true
  612. row.Edit = false
  613. row.NoEdit = true
  614. // 新增false,编辑true,编辑保存false
  615. row.isCreate = false
  616. row.isUpdate = true
  617. row.isUpdateSave = false
  618. this.getList()
  619. this.dropState = false
  620. },
  621. handleSelect(val) {
  622. console.log('勾选数据', val)
  623. this.selectList = val
  624. },
  625. // 行内删除
  626. handleRowDelete(row) {
  627. console.log(row, '点击了行删除')
  628. MessageBox.confirm('是否确认删除此信息?', {
  629. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  630. }).then(() => {
  631. this.selectList = []
  632. this.requestParam = {}
  633. this.requestParam.name = 'deleteRemainplan'
  634. this.requestParam.parammaps = {}
  635. this.requestParam.parammaps.pastureid = row.pastureid
  636. this.requestParam.parammaps.id = row.id
  637. PostDataByName(this.requestParam).then(response => {
  638. if (response.msg === 'fail') {
  639. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  640. } else {
  641. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  642. this.getList()
  643. }
  644. })
  645. }).catch(() => {
  646. this.$message({ type: 'info', message: '已取消删除' })
  647. })
  648. },
  649. // 减少车次
  650. handleDelete() {
  651. if (this.selectList.length == 0) {
  652. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  653. } else {
  654. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  655. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  656. }).then(() => {
  657. console.log(this.selectList)
  658. this.requestParam.common = { 'returnmap': '0' }
  659. this.requestParam.data = []
  660. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  661. this.requestParam.data[0].children = []
  662. this.requestParam.data[0].children[0] = { 'name': 'deleteRemainplan', 'type': 'e', 'parammaps': {
  663. id: '@insertSpotList.id',
  664. pastureid: '@insertSpotList.pastureid'
  665. }}
  666. ExecDataByConfig(this.requestParam).then(response => {
  667. console.log('删除保存发送参数', this.requestParam)
  668. if (response.msg === 'fail') {
  669. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  670. } else {
  671. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  672. this.getList()
  673. }
  674. })
  675. })
  676. }
  677. },
  678. // 历史记录
  679. handleHistoryRecords() {
  680. console.log('点击了历史记录')
  681. this.history.dialogStatus = 'history'
  682. this.history.dialogFormVisible = true
  683. this.getDateList()
  684. },
  685. // 历史时间
  686. getDateList() {
  687. GetDataByName(this.history.getdataDateParm).then(response => {
  688. console.log('table数据', response.data.list)
  689. if (response.data.list !== null) {
  690. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  691. this.getHistoryList()
  692. } else {
  693. this.history.getdataListParm.parammaps.date = ''
  694. }
  695. })
  696. },
  697. changeDate() {
  698. this.getHistoryList()
  699. },
  700. // 应用
  701. handleApplication() {
  702. console.log('点击了应用')
  703. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  704. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  705. }).then(() => {
  706. this.requestParam.name = 'applyFPdate'
  707. this.requestParam.parammaps = {}
  708. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  709. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  710. PostDataByName(this.requestParam).then(response => {
  711. if (response.msg === 'fail') {
  712. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  713. } else {
  714. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  715. this.getHistoryIsDisplay()
  716. this.getList()
  717. }
  718. })
  719. }).catch(() => {
  720. this.$message({ type: 'info', message: '已取消应用' })
  721. })
  722. },
  723. getHistoryList() {
  724. this.history.listLoading = true
  725. GetDataByName(this.history.getdataListParm).then(response => {
  726. console.log('table数据', response.data.list)
  727. if (response.data.list !== null) {
  728. console.log('table数据', response.data.list)
  729. this.history.list = response.data.list
  730. this.history.pageNum = response.data.pageNum
  731. this.history.pageSize = response.data.pageSize
  732. this.history.total = response.data.total
  733. } else {
  734. this.history.list = []
  735. }
  736. setTimeout(() => {
  737. this.history.listLoading = false
  738. }, 100)
  739. })
  740. }
  741. }
  742. }
  743. </script>
  744. <style lang="scss" scoped>
  745. .search{clear: both;}
  746. .table{margin-top:10px;}
  747. </style>