7d9797d6b3257e495d0550b8a791504a085358cd.svn-base 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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: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 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="cancel" @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. row.lppcode = this.carFollowList.find(obj => obj.id == item).lppcode
  342. },
  343. // 班次
  344. changeTimes(item, row) {
  345. console.log(item, row)
  346. this.getCarFollowParm.parammaps.times = item
  347. this.getCarFollowList(row)
  348. },
  349. // 撒料计划车次跟随列表
  350. getCarFollowList(row) {
  351. GetDataByName(this.getCarFollowParm).then(response => {
  352. console.log('撒料计划车次跟随列表数据', response.data.list)
  353. if (response.data.list !== null) {
  354. this.carFollowList = response.data.list
  355. row.lppid = this.carFollowList[0].id
  356. row.lppcode = this.carFollowList[0].lppcode
  357. }
  358. })
  359. },
  360. handleEnableChange() {
  361. console.log('点击了生效')
  362. },
  363. // 行拖拽
  364. rowDrop() {
  365. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  366. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  367. const that = this
  368. var sortable = Sortable.create(tbody, {
  369. disabled: that.dropState,
  370. onChoose({ newIndex, oldIndex }) {
  371. if (that.dropState == true) {
  372. sortable.destroy()
  373. }
  374. },
  375. onEnd({ newIndex, oldIndex }) {
  376. const currRow = that.table.list.splice(oldIndex, 1)[0]
  377. that.table.list.splice(newIndex, 0, currRow)
  378. console.log('索引', newIndex)
  379. console.log('拖动数据', currRow)
  380. console.log('上', that.table.list[newIndex - 1])
  381. console.log('下', that.table.list[newIndex + 1])
  382. }
  383. })
  384. },
  385. // 模板新增
  386. handleCreate() {
  387. this.dropState = true
  388. console.log('点击了新增车次')
  389. // 编辑true/不可编辑false
  390. // 新增操true,编辑false,编辑保存false
  391. for (let i = 0; i < this.table.list.length; i++) {
  392. if (this.table.list[i].Edit === true) {
  393. console.log(123)
  394. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  395. return false
  396. }
  397. }
  398. 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': '', 'ptime': '', 'maxweight': '', 'operateweight': '' })
  399. },
  400. createData(row) {
  401. console.log('点击了新增保存', row)
  402. if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  403. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  404. return false
  405. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  406. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  407. return false
  408. } else if (row.times == '' && row.operateweight == '') {
  409. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  410. return false
  411. } else if (row.ftid == '') {
  412. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  413. return false
  414. } else if (row.tmrid == '') {
  415. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  416. return false
  417. } else if (row.times == '') {
  418. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  419. return false
  420. } else if (row.operateweight == '') {
  421. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  422. return false
  423. }
  424. for (let i = 0; i < this.table.list.length; i++) {
  425. if (row.sort == this.table.list[i].sort) {
  426. if (row.id !== this.table.list[i].id) {
  427. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  428. return false
  429. }
  430. }
  431. }
  432. var isInteger = /^\d+$/
  433. if (row.sort !== '') {
  434. if (!isInteger.test(parseFloat(row.sort))) {
  435. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  436. return false
  437. }
  438. }
  439. this.isokDisable = true
  440. setTimeout(() => {
  441. this.isokDisable = false
  442. }, 1000)
  443. this.requestParam.name = 'insertPremixplan'
  444. this.requestParam.parammaps = row
  445. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  446. PostDataByName(this.requestParam).then(response => {
  447. console.log('新增保存发送参数', this.requestParam)
  448. if (response.msg !== 'fail') {
  449. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  450. this.getList()
  451. this.dropState = false
  452. } else {
  453. failproccess(response, this.$notify)
  454. }
  455. })
  456. },
  457. createCancel(row) {
  458. console.log('点击了新增取消')
  459. this.dropState = false
  460. for (let i = 0; i < this.table.list.length; i++) {
  461. if (row.myId === this.table.list[i].myId) {
  462. var listIndex = this.table.list.indexOf(this.table.list[i])
  463. }
  464. if (listIndex > -1) {
  465. this.table.list.splice(listIndex, 1)
  466. return
  467. }
  468. }
  469. },
  470. // 模板编辑
  471. handleUpdate(row) {
  472. for (let i = 0; i < this.table.list.length; i++) {
  473. if (this.table.list[i].Edit == true) {
  474. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  475. return false
  476. }
  477. }
  478. // 编辑true,不可编辑false
  479. row.Edit = true
  480. row.NoEdit = false
  481. // 新增false,编辑false,编辑保存true
  482. row.isCreate = false
  483. row.isUpdate = false
  484. row.isUpdateSave = true
  485. row.lppid = String(row.lppid)
  486. this.getCarFollowParm.parammaps.times = row.times
  487. this.getCarFollowList(row)
  488. this.dropState = true
  489. },
  490. updateData(row) {
  491. console.log('点击了编辑保存', row)
  492. if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  493. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  494. return false
  495. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  496. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  497. return false
  498. } else if (row.times == '' && row.operateweight == '') {
  499. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  500. return false
  501. } else if (row.ftid == '') {
  502. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  503. return false
  504. } else if (row.tmrid == '') {
  505. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  506. return false
  507. } else if (row.times == '') {
  508. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  509. return false
  510. } else if (row.operateweight == '') {
  511. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  512. return false
  513. }
  514. for (let i = 0; i < this.table.list.length; i++) {
  515. if (row.sort == this.table.list[i].sort) {
  516. if (row.id !== this.table.list[i].id) {
  517. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  518. return false
  519. }
  520. }
  521. }
  522. var isInteger = /^\d+$/
  523. if (row.sort !== '') {
  524. if (!isInteger.test(parseFloat(row.sort))) {
  525. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  526. return false
  527. }
  528. }
  529. this.isokDisable = true
  530. setTimeout(() => {
  531. this.isokDisable = false
  532. }, 1000)
  533. this.requestParam.name = 'updatePremixplan'
  534. this.requestParam.parammaps = row
  535. PostDataByName(this.requestParam).then(response => {
  536. console.log('新增保存发送参数', this.requestParam)
  537. if (response.msg !== 'fail') {
  538. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  539. this.getList()
  540. this.dropState = false
  541. } else {
  542. failproccess(response, this.$notify)
  543. }
  544. })
  545. },
  546. updateCancel(row) {
  547. console.log('点击了编辑取消')
  548. // 编辑false,不可编辑true
  549. row.Edit = false
  550. row.NoEdit = true
  551. // 新增false,编辑true,编辑保存false
  552. row.isCreate = false
  553. row.isUpdate = true
  554. row.isUpdateSave = false
  555. this.getList()
  556. this.dropState = false
  557. },
  558. handleSelect(val) {
  559. console.log('勾选数据', val)
  560. this.selectList = val
  561. },
  562. // 历史记录
  563. handleHistoryRecords() {
  564. console.log('点击了历史记录')
  565. this.history.dialogStatus = 'history'
  566. this.history.dialogFormVisible = true
  567. this.getDateList()
  568. },
  569. // 历史时间
  570. getDateList() {
  571. GetDataByName(this.history.getdataDateParm).then(response => {
  572. console.log('table数据', response.data.list)
  573. if (response.data.list !== null) {
  574. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  575. this.getHistoryList()
  576. } else {
  577. this.history.getdataListParm.parammaps.date = ''
  578. }
  579. })
  580. },
  581. changeDate() {
  582. this.getHistoryList()
  583. },
  584. // 应用
  585. handleApplication() {
  586. console.log('点击了应用')
  587. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  588. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  589. }).then(() => {
  590. this.requestParam.name = 'applyFPdate'
  591. this.requestParam.parammaps = {}
  592. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  593. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  594. PostDataByName(this.requestParam).then(response => {
  595. if (response.msg === 'fail') {
  596. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  597. } else {
  598. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  599. this.getHistoryIsDisplay()
  600. this.getList()
  601. }
  602. })
  603. }).catch(() => {
  604. this.$message({ type: 'info', message: '已取消应用' })
  605. })
  606. },
  607. getHistoryList() {
  608. this.history.listLoading = true
  609. GetDataByName(this.history.getdataListParm).then(response => {
  610. console.log('table数据', response.data.list)
  611. if (response.data.list !== null) {
  612. console.log('table数据', response.data.list)
  613. this.history.list = response.data.list
  614. this.history.pageNum = response.data.pageNum
  615. this.history.pageSize = response.data.pageSize
  616. this.history.total = response.data.total
  617. } else {
  618. this.history.list = []
  619. }
  620. setTimeout(() => {
  621. this.history.listLoading = false
  622. }, 100)
  623. })
  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 = 'deletePremixplan'
  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': 'deletePremixplan', '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. }
  680. </script>
  681. <style lang="scss" scoped>
  682. .search{clear: both;}
  683. .table{margin-top:10px;}
  684. </style>