90dd3e598917a80d477f94b3f2515dae24048231.svn-base 30 KB

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