1ed835ad7f5a7bb66412b1e0bec2ffce7bfb2c17.svn-base 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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="130px" 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="130px" align="center">
  35. <template slot-scope="scope">
  36. <span v-if="scope.row.NoEdit">{{ scope.row.bar }}</span>
  37. <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)}">
  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="130px" 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="130px" 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="130px" 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="130px" 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 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="180px" 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.useinbar }}</span>
  88. <el-select v-if="scope.row.Edit" v-model="scope.row.useinbarid" :disabled="scope.row.treatmethod == '继续饲喂'" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeTransferbars(value, scope.row)}">
  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="320" 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.bar }}</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.useinbar }}</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>当前有栏舍未分配,建议及时进行分配,未分配栏舍如下:</p>
  185. 1-6;1-7;1-8
  186. </div>
  187. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  188. <el-button class="miniSuccess" @click="check.dialogFormVisible=false;">确认</el-button>
  189. </div>
  190. </el-dialog>
  191. </div>
  192. </template>
  193. <script>
  194. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  195. import Pagination from '@/components/Pagination'
  196. import Sortable from 'sortablejs'
  197. import Cookies from 'js-cookie'
  198. import { MessageBox } from 'element-ui'
  199. export default {
  200. name: 'SurplusMaterialPlan',
  201. components: { Pagination },
  202. data() {
  203. return {
  204. requestParams: [
  205. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  206. { name: 'getTMRYHList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  207. ],
  208. barsList: [], // 栏舍
  209. residueDisposalList: [{ value: '0', label: '转投剩料' }, { value: '1', label: '继续饲喂' }], // 剩料处理方式
  210. TMRNumberList: [], // TMR编号
  211. // 班次
  212. maxTime: {
  213. getMaxTimesParm: {
  214. name: 'getSysoptEnable',
  215. page: 1,
  216. offset: 1,
  217. pagecount: 1,
  218. returntype: 'Map',
  219. parammaps: {
  220. pastureid: Cookies.get('pastureid'),
  221. inforname: 'times'
  222. }
  223. }
  224. },
  225. frequencyList: [], // 班次
  226. getCarFollowParm: {
  227. name: 'getLPPCodeList',
  228. offset: 0,
  229. pagecount: 0,
  230. parammaps: {
  231. pastureid: Cookies.get('pastureid'),
  232. times: ''
  233. }
  234. },
  235. carFollowList: [], // 发料计划车次跟随
  236. getTransferbarsParm: {
  237. name: 'getBarListEnable',
  238. offset: 0,
  239. pagecount: 0,
  240. parammaps: {
  241. pastureid: Cookies.get('pastureid'),
  242. times: ''
  243. }
  244. },
  245. transferbarsList: [], // 转头栏舍
  246. table: {
  247. getdataListParm: {
  248. name: 'getRemainplanList',
  249. page: 1,
  250. offset: 1,
  251. pagecount: 10,
  252. returntype: 'Map',
  253. parammaps: {
  254. pastureid: Cookies.get('pastureid')
  255. }
  256. },
  257. tableKey: 0,
  258. list: [],
  259. total: 0,
  260. listLoading: true
  261. },
  262. history: {
  263. dialogFormVisible: false,
  264. dialogStatus: '',
  265. temp: {},
  266. rules: {},
  267. tableKey: 0,
  268. list: [],
  269. total: 0,
  270. listLoading: true,
  271. getdataDateParm: {
  272. name: 'getRPMaxDate',
  273. page: 1,
  274. offset: 1,
  275. pagecount: 10,
  276. returntype: 'Map',
  277. parammaps: {
  278. pastureid: Cookies.get('pastureid')
  279. }
  280. },
  281. getdataListParm: {
  282. name: 'getRemainplanListDate',
  283. page: 1,
  284. offset: 1,
  285. pagecount: 10,
  286. returntype: 'Map',
  287. parammaps: {
  288. pastureid: Cookies.get('pastureid'),
  289. date: ''
  290. }
  291. }
  292. },
  293. check: {
  294. dialogFormVisible: false,
  295. dialogStatus: ''
  296. },
  297. textMap: {
  298. history: '历史记录',
  299. check: '提示'
  300. },
  301. requestParam: {},
  302. selectList: [],
  303. isokDisable: false,
  304. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  305. cellStyle: { padding: 0 + 'px' },
  306. dropState: false
  307. }
  308. },
  309. created() {
  310. this.getList()
  311. this.getDownList()
  312. this.getIsDisplay()
  313. },
  314. methods: {
  315. getDownList() {
  316. GetDataByNames(this.requestParams).then(response => {
  317. this.barsList = response.data.getBarListEnable.list
  318. this.TMRNumberList = response.data.getTMRYHList.list
  319. })
  320. },
  321. getIsDisplay() {
  322. GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
  323. if (response.data.list[0].inforvalue == 1) {
  324. this.frequencyList = [{ id: '1', name: '第一班' }]
  325. } else if (response.data.list[0].inforvalue == 2) {
  326. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
  327. } else if (response.data.list[0].inforvalue == 3) {
  328. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  329. } else if (response.data.list[0].inforvalue == 4) {
  330. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  331. }
  332. })
  333. },
  334. getList() {
  335. this.table.listLoading = true
  336. GetDataByName(this.table.getdataListParm).then(response => {
  337. console.log('table数据', response.data.list)
  338. if (response.data.list !== null) {
  339. for (let i = 0; i < response.data.list.length; i++) {
  340. this.$set(response.data.list[i], 'Edit', false) // 编辑
  341. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  342. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  343. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  344. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  345. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  346. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  347. }
  348. this.table.list = response.data.list
  349. this.table.pageNum = response.data.pageNum
  350. this.table.pageSize = response.data.pageSize
  351. this.rowDrop()
  352. this.table.total = response.data.total
  353. } else {
  354. this.table.list = []
  355. }
  356. setTimeout(() => {
  357. this.table.listLoading = false
  358. }, 100)
  359. })
  360. },
  361. handleEnableChange() {
  362. console.log('点击了生效')
  363. },
  364. // 行拖拽
  365. rowDrop() {
  366. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  367. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  368. const that = this
  369. var sortable = Sortable.create(tbody, {
  370. disabled: that.dropState,
  371. onChoose({ newIndex, oldIndex }) {
  372. if (that.dropState == true) {
  373. sortable.destroy()
  374. }
  375. },
  376. onEnd({ newIndex, oldIndex }) {
  377. const currRow = that.table.list.splice(oldIndex, 1)[0]
  378. that.table.list.splice(newIndex, 0, currRow)
  379. console.log('索引', newIndex)
  380. console.log('拖动数据', currRow)
  381. console.log('上', that.table.list[newIndex - 1])
  382. console.log('下', that.table.list[newIndex + 1])
  383. }
  384. })
  385. },
  386. // 模板新增
  387. handleCreate() {
  388. console.log('点击了新增车次')
  389. // 编辑true/不可编辑false
  390. // 新增操true,编辑false,编辑保存false
  391. this.dropState = true
  392. for (let i = 0; i < this.table.list.length; i++) {
  393. if (this.table.list[i].Edit === true) {
  394. console.log(123)
  395. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  396. return false
  397. }
  398. }
  399. var sort = 0
  400. if (this.table.list.length > 0) {
  401. sort = parseInt(this.table.list[this.table.list.length - 1].sort) + 1
  402. } else {
  403. sort = '0'
  404. }
  405. 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': '' })
  406. console.log(this.table.list)
  407. },
  408. // 栏舍
  409. changeBars(item, row) {
  410. row.bar = this.barsList.find(obj => obj.id == item).bname
  411. },
  412. // TMR编号
  413. changeTMRNumber(item, row) {
  414. row.tmrcode = this.TMRNumberList.find(obj => obj.id == item).tname
  415. },
  416. // 撒料计划车次跟随列表
  417. changeCarFollow(item, row) {
  418. row.lppcode = this.carFollowList.find(obj => obj.id == item).lppcode
  419. },
  420. // 班次
  421. changeTimes(item, row) {
  422. console.log(item, row)
  423. this.getCarFollowParm.parammaps.times = item
  424. this.getCarFollowList(row)
  425. },
  426. // 撒料计划车次跟随列表
  427. getCarFollowList(row) {
  428. GetDataByName(this.getCarFollowParm).then(response => {
  429. console.log('撒料计划车次跟随列表数据', response.data.list)
  430. if (response.data.list !== null) {
  431. this.carFollowList = response.data.list
  432. row.lppid = this.carFollowList[0].id
  433. row.lppcode = this.carFollowList[0].lppcode
  434. }
  435. })
  436. },
  437. changeResidueDisposal(item, row) {
  438. console.log(item, row)
  439. this.getCarFollowParm.parammaps.times = item
  440. this.getTransferbarsList()
  441. },
  442. getTransferbarsList() {
  443. GetDataByName(this.getTransferbarsParm).then(response => {
  444. console.log('撒料计划车次跟随列表数据', response.data.list)
  445. if (response.data.list !== null) {
  446. this.transferbarsList = response.data.list
  447. }
  448. })
  449. },
  450. // 转头栏舍
  451. changeTransferbars(item, row) {
  452. console.log(item, row)
  453. row.useinbar = this.transferbarsList.find(obj => obj.id == item).bname
  454. },
  455. createData(row) {
  456. console.log('点击了新增保存', row)
  457. if (row.sort == '' && row.barid == '' && row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  458. this.$message({ type: 'error', message: '车次/栏舍/TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  459. return false
  460. } else if (row.barid == '' && row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  461. this.$message({ type: 'error', message: '栏舍/TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  462. return false
  463. } else if (row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  464. this.$message({ type: 'error', message: 'TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  465. return false
  466. } else if (row.times == '' && row.treatmethod == '') {
  467. this.$message({ type: 'error', message: '班次/剩料处理方式不能为空', duration: 2000 })
  468. return false
  469. } else if (row.sort == '') {
  470. console.log(row.sort, 0 == '')
  471. this.$message({ type: 'error', message: '车次不能为空', duration: 2000 })
  472. return false
  473. } else if (row.barid == '') {
  474. this.$message({ type: 'error', message: '栏舍不能为空', duration: 2000 })
  475. return false
  476. } else if (row.tmrid == '') {
  477. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  478. return false
  479. } else if (row.times == '') {
  480. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  481. return false
  482. } else if (row.treatmethod == '') {
  483. this.$message({ type: 'error', message: '剩料处理方式不能为空', duration: 2000 })
  484. return false
  485. }
  486. if (row.treatmethod !== '' && row.treatmethod == '转投剩料') {
  487. if (row.useinbarid == '') {
  488. this.$message({ type: 'error', message: '转投栏舍不能为空', duration: 2000 })
  489. return false
  490. }
  491. }
  492. if (row.treatmethod !== '' && row.treatmethod == '继续饲喂') {
  493. row.useinbarid = '0'
  494. }
  495. if (row.rtime == '' || row.rtime == null) {
  496. row.rtime = ''
  497. }
  498. for (let i = 0; i < this.table.list.length; i++) {
  499. if (row.sort == this.table.list[i].sort) {
  500. if (row.myId !== this.table.list[i].myId) {
  501. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  502. return false
  503. }
  504. }
  505. }
  506. var isInteger = /^\d+$/
  507. if (row.sort !== '') {
  508. if (!isInteger.test(parseFloat(row.sort))) {
  509. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  510. return false
  511. }
  512. }
  513. this.isokDisable = true
  514. setTimeout(() => {
  515. this.isokDisable = false
  516. }, 1000)
  517. this.requestParam.name = 'insertRemainplan'
  518. this.requestParam.parammaps = row
  519. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  520. PostDataByName(this.requestParam).then(response => {
  521. console.log('新增保存发送参数', this.requestParam)
  522. if (response.msg !== 'fail') {
  523. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  524. this.getList()
  525. this.dropState = false
  526. } else {
  527. failproccess(response, this.$notify)
  528. }
  529. })
  530. },
  531. createCancel(row) {
  532. console.log('点击了新增取消')
  533. this.dropState = false
  534. for (let i = 0; i < this.table.list.length; i++) {
  535. if (row.myId === this.table.list[i].myId) {
  536. var listIndex = this.table.list.indexOf(this.table.list[i])
  537. }
  538. if (listIndex > -1) {
  539. this.table.list.splice(listIndex, 1)
  540. return
  541. }
  542. }
  543. },
  544. // 模板编辑
  545. handleUpdate(row) {
  546. for (let i = 0; i < this.table.list.length; i++) {
  547. if (this.table.list[i].Edit == true) {
  548. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  549. return false
  550. }
  551. }
  552. // 编辑true,不可编辑false
  553. row.Edit = true
  554. row.NoEdit = false
  555. // 新增false,编辑false,编辑保存true
  556. row.isCreate = false
  557. row.isUpdate = false
  558. row.isUpdateSave = true
  559. if (row.useinbarid == '0') { row.useinbarid = '' }
  560. if (row.barid == undefined) { row.barid = '' }
  561. if (row.tmrid == undefined) { row.tmrid = '' }
  562. if (row.times == undefined) { row.times = '' }
  563. if (row.useinbarid == undefined) { row.useinbarid = '' }
  564. if (row.treatmethod == undefined) { row.treatmethod = '' }
  565. this.getCarFollowParm.parammaps.times = row.times
  566. if (this.getCarFollowParm.parammaps.times == '第一班') {
  567. this.getCarFollowParm.parammaps.times = 1
  568. } else if (this.getCarFollowParm.parammaps.times == '第二班') {
  569. this.getCarFollowParm.parammaps.times = 2
  570. } else if (this.getCarFollowParm.parammaps.times == '第三班') {
  571. this.getCarFollowParm.parammaps.times = 3
  572. } else if (this.getCarFollowParm.parammaps.times == '第四班') {
  573. this.getCarFollowParm.parammaps.times = 4
  574. } else if (this.getCarFollowParm.parammaps.times == '第五班') {
  575. this.getCarFollowParm.parammaps.times = 5
  576. }
  577. this.getCarFollowList(row)
  578. this.dropState = true
  579. },
  580. updateData(row) {
  581. console.log('点击了编辑保存', row)
  582. if (row.barid == '' && row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  583. this.$message({ type: 'error', message: '栏舍/TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  584. return false
  585. } else if (row.tmrid == '' && row.times == '' && row.treatmethod == '') {
  586. this.$message({ type: 'error', message: 'TMR编号/班次/剩料处理方式不能为空', duration: 2000 })
  587. return false
  588. } else if (row.times == '' && row.treatmethod == '') {
  589. this.$message({ type: 'error', message: '班次/混剩料处理方式不能为空', duration: 2000 })
  590. return false
  591. } else if (row.barid == '') {
  592. this.$message({ type: 'error', message: '栏舍不能为空', duration: 2000 })
  593. return false
  594. } else if (row.tmrid == '') {
  595. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  596. return false
  597. } else if (row.times == '') {
  598. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  599. return false
  600. } else if (row.treatmethod == '') {
  601. this.$message({ type: 'error', message: '剩料处理方式不能为空', duration: 2000 })
  602. return false
  603. }
  604. if (row.treatmethod !== '' && row.treatmethod == '转投剩料') {
  605. if (row.useinbarid == '') {
  606. this.$message({ type: 'error', message: '转投栏舍不能为空', duration: 2000 })
  607. return false
  608. }
  609. }
  610. if (row.treatmethod !== '' && row.treatmethod == '继续饲喂') {
  611. row.useinbarid = '0'
  612. }
  613. if (row.rtime == '' || row.rtime == null) {
  614. row.rtime = ''
  615. }
  616. for (let i = 0; i < this.table.list.length; i++) {
  617. if (row.sort == this.table.list[i].sort) {
  618. if (row.id !== this.table.list[i].id) {
  619. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  620. return false
  621. }
  622. }
  623. }
  624. var isInteger = /^\d+$/
  625. if (row.sort !== '') {
  626. if (!isInteger.test(parseFloat(row.sort))) {
  627. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  628. return false
  629. }
  630. }
  631. this.isokDisable = true
  632. setTimeout(() => {
  633. this.isokDisable = false
  634. }, 1000)
  635. this.requestParam.name = 'updateRemainplan'
  636. this.requestParam.parammaps = row
  637. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  638. PostDataByName(this.requestParam).then(response => {
  639. console.log('新增保存发送参数', this.requestParam)
  640. if (response.msg !== 'fail') {
  641. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  642. this.getList()
  643. this.dropState = false
  644. } else {
  645. failproccess(response, this.$notify)
  646. }
  647. })
  648. },
  649. updateCancel(row) {
  650. console.log('点击了编辑取消')
  651. // 编辑false,不可编辑true
  652. row.Edit = false
  653. row.NoEdit = true
  654. // 新增false,编辑true,编辑保存false
  655. row.isCreate = false
  656. row.isUpdate = true
  657. row.isUpdateSave = false
  658. this.getList()
  659. this.dropState = false
  660. },
  661. handleSelect(val) {
  662. console.log('勾选数据', val)
  663. this.selectList = val
  664. },
  665. // 行内删除
  666. handleRowDelete(row) {
  667. console.log(row, '点击了行删除')
  668. MessageBox.confirm('是否确认删除此信息?', {
  669. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  670. }).then(() => {
  671. this.selectList = []
  672. this.requestParam = {}
  673. this.requestParam.name = 'deleteRemainplan'
  674. this.requestParam.parammaps = {}
  675. this.requestParam.parammaps.pastureid = row.pastureid
  676. this.requestParam.parammaps.id = row.id
  677. PostDataByName(this.requestParam).then(response => {
  678. if (response.msg === 'fail') {
  679. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  680. } else {
  681. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  682. this.getList()
  683. }
  684. })
  685. }).catch(() => {
  686. this.$message({ type: 'info', message: '已取消删除' })
  687. })
  688. },
  689. // 减少车次
  690. handleDelete() {
  691. if (this.selectList.length == 0) {
  692. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  693. } else {
  694. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  695. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  696. }).then(() => {
  697. console.log(this.selectList)
  698. this.requestParam.common = { 'returnmap': '0' }
  699. this.requestParam.data = []
  700. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  701. this.requestParam.data[0].children = []
  702. this.requestParam.data[0].children[0] = { 'name': 'deleteRemainplan', 'type': 'e', 'parammaps': {
  703. id: '@insertSpotList.id',
  704. pastureid: '@insertSpotList.pastureid'
  705. }}
  706. ExecDataByConfig(this.requestParam).then(response => {
  707. console.log('删除保存发送参数', this.requestParam)
  708. if (response.msg === 'fail') {
  709. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  710. } else {
  711. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  712. this.getList()
  713. }
  714. })
  715. })
  716. }
  717. },
  718. // 校验
  719. handleCheck() {
  720. console.log('点击了校验')
  721. this.check.dialogStatus = 'check'
  722. this.check.dialogFormVisible = true
  723. },
  724. // 历史记录
  725. handleHistoryRecords() {
  726. console.log('点击了历史记录')
  727. this.history.dialogStatus = 'history'
  728. this.history.dialogFormVisible = true
  729. this.getDateList()
  730. },
  731. // 历史时间
  732. getDateList() {
  733. GetDataByName(this.history.getdataDateParm).then(response => {
  734. console.log('table数据', response.data.list)
  735. if (response.data.list !== null) {
  736. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  737. this.getHistoryList()
  738. } else {
  739. this.history.getdataListParm.parammaps.date = ''
  740. }
  741. })
  742. },
  743. changeDate() {
  744. this.getHistoryList()
  745. },
  746. // 应用
  747. handleApplication() {
  748. console.log('点击了应用')
  749. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  750. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  751. }).then(() => {
  752. this.requestParam.name = 'applyFPdate'
  753. this.requestParam.parammaps = {}
  754. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  755. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  756. PostDataByName(this.requestParam).then(response => {
  757. if (response.msg === 'fail') {
  758. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  759. } else {
  760. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  761. this.getHistoryIsDisplay()
  762. this.getList()
  763. }
  764. })
  765. }).catch(() => {
  766. this.$message({ type: 'info', message: '已取消应用' })
  767. })
  768. },
  769. getHistoryList() {
  770. this.history.listLoading = true
  771. GetDataByName(this.history.getdataListParm).then(response => {
  772. console.log('table数据', response.data.list)
  773. if (response.data.list !== null) {
  774. console.log('table数据', response.data.list)
  775. this.history.list = response.data.list
  776. this.history.pageNum = response.data.pageNum
  777. this.history.pageSize = response.data.pageSize
  778. this.history.total = response.data.total
  779. } else {
  780. this.history.list = []
  781. }
  782. setTimeout(() => {
  783. this.history.listLoading = false
  784. }, 100)
  785. })
  786. }
  787. }
  788. }
  789. </script>
  790. <style lang="scss" scoped>
  791. .search{clear: both;}
  792. .table{margin-top:10px;}
  793. </style>