8cb6e2df871eb5fd03cab644f1b9e0e111613366.svn-base 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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 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. 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. var sort = 0
  399. if (this.table.list.length > 0) {
  400. sort = parseInt(this.table.list[this.table.list.length - 1].sort) + 1
  401. } else {
  402. sort = 0
  403. }
  404. 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': '' })
  405. },
  406. createData(row) {
  407. console.log('点击了新增保存', row)
  408. if (row.sort == '' && row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  409. this.$message({ type: 'error', message: '车次/配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  410. return false
  411. } else if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  412. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  413. return false
  414. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  415. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  416. return false
  417. } else if (row.times == '' && row.operateweight == '') {
  418. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  419. return false
  420. } else if (row.sort == '') {
  421. this.$message({ type: 'error', message: '车次不能为空', duration: 2000 })
  422. return false
  423. } else if (row.ftid == '') {
  424. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  425. return false
  426. } else if (row.tmrid == '') {
  427. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  428. return false
  429. } else if (row.times == '') {
  430. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  431. return false
  432. } else if (row.operateweight == '') {
  433. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  434. return false
  435. }
  436. for (let i = 0; i < this.table.list.length; i++) {
  437. if (row.sort !== '') {
  438. if (row.sort == this.table.list[i].sort) {
  439. if (row.myId !== this.table.list[i].myId) {
  440. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  441. return false
  442. }
  443. }
  444. }
  445. }
  446. var isInteger = /^\d+$/
  447. if (row.sort !== '') {
  448. if (!isInteger.test(parseFloat(row.sort))) {
  449. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  450. return false
  451. }
  452. }
  453. this.isokDisable = true
  454. setTimeout(() => {
  455. this.isokDisable = false
  456. }, 1000)
  457. this.requestParam.name = 'insertPremixplan'
  458. this.requestParam.parammaps = row
  459. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  460. PostDataByName(this.requestParam).then(response => {
  461. console.log('新增保存发送参数', this.requestParam)
  462. if (response.msg !== 'fail') {
  463. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  464. this.getList()
  465. this.dropState = false
  466. } else {
  467. failproccess(response, this.$notify)
  468. }
  469. })
  470. },
  471. createCancel(row) {
  472. console.log('点击了新增取消')
  473. this.dropState = false
  474. for (let i = 0; i < this.table.list.length; i++) {
  475. if (row.myId === this.table.list[i].myId) {
  476. var listIndex = this.table.list.indexOf(this.table.list[i])
  477. }
  478. if (listIndex > -1) {
  479. this.table.list.splice(listIndex, 1)
  480. return
  481. }
  482. }
  483. },
  484. // 模板编辑
  485. handleUpdate(row) {
  486. for (let i = 0; i < this.table.list.length; i++) {
  487. if (this.table.list[i].Edit == true) {
  488. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  489. return false
  490. }
  491. }
  492. // 编辑true,不可编辑false
  493. row.Edit = true
  494. row.NoEdit = false
  495. // 新增false,编辑false,编辑保存true
  496. row.isCreate = false
  497. row.isUpdate = false
  498. row.isUpdateSave = true
  499. row.lppid = String(row.lppid)
  500. this.getCarFollowParm.parammaps.times = row.times
  501. this.getCarFollowList(row)
  502. this.dropState = true
  503. },
  504. updateData(row) {
  505. console.log('点击了编辑保存', row)
  506. if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  507. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  508. return false
  509. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  510. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  511. return false
  512. } else if (row.times == '' && row.operateweight == '') {
  513. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  514. return false
  515. } else if (row.ftid == '') {
  516. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  517. return false
  518. } else if (row.tmrid == '') {
  519. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  520. return false
  521. } else if (row.times == '') {
  522. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  523. return false
  524. } else if (row.operateweight == '') {
  525. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  526. return false
  527. }
  528. for (let i = 0; i < this.table.list.length; i++) {
  529. if (row.sort == this.table.list[i].sort) {
  530. if (row.id !== this.table.list[i].id) {
  531. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  532. return false
  533. }
  534. }
  535. }
  536. var isInteger = /^\d+$/
  537. if (row.sort !== '') {
  538. if (!isInteger.test(parseFloat(row.sort))) {
  539. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  540. return false
  541. }
  542. }
  543. this.isokDisable = true
  544. setTimeout(() => {
  545. this.isokDisable = false
  546. }, 1000)
  547. this.requestParam.name = 'updatePremixplan'
  548. this.requestParam.parammaps = row
  549. PostDataByName(this.requestParam).then(response => {
  550. console.log('新增保存发送参数', this.requestParam)
  551. if (response.msg !== 'fail') {
  552. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  553. this.getList()
  554. this.dropState = false
  555. } else {
  556. failproccess(response, this.$notify)
  557. }
  558. })
  559. },
  560. updateCancel(row) {
  561. console.log('点击了编辑取消')
  562. // 编辑false,不可编辑true
  563. row.Edit = false
  564. row.NoEdit = true
  565. // 新增false,编辑true,编辑保存false
  566. row.isCreate = false
  567. row.isUpdate = true
  568. row.isUpdateSave = false
  569. this.getList()
  570. this.dropState = false
  571. },
  572. handleSelect(val) {
  573. console.log('勾选数据', val)
  574. this.selectList = val
  575. },
  576. // 历史记录
  577. handleHistoryRecords() {
  578. console.log('点击了历史记录')
  579. this.history.dialogStatus = 'history'
  580. this.history.dialogFormVisible = true
  581. this.getDateList()
  582. },
  583. // 历史时间
  584. getDateList() {
  585. GetDataByName(this.history.getdataDateParm).then(response => {
  586. console.log('table数据', response.data.list)
  587. if (response.data.list !== null) {
  588. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  589. this.getHistoryList()
  590. } else {
  591. this.history.getdataListParm.parammaps.date = ''
  592. }
  593. })
  594. },
  595. changeDate() {
  596. this.getHistoryList()
  597. },
  598. // 应用
  599. handleApplication() {
  600. console.log('点击了应用')
  601. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  602. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  603. }).then(() => {
  604. this.requestParam.name = 'applyFPdate'
  605. this.requestParam.parammaps = {}
  606. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  607. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  608. PostDataByName(this.requestParam).then(response => {
  609. if (response.msg === 'fail') {
  610. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  611. } else {
  612. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  613. this.getHistoryIsDisplay()
  614. this.getList()
  615. }
  616. })
  617. }).catch(() => {
  618. this.$message({ type: 'info', message: '已取消应用' })
  619. })
  620. },
  621. getHistoryList() {
  622. this.history.listLoading = true
  623. GetDataByName(this.history.getdataListParm).then(response => {
  624. console.log('table数据', response.data.list)
  625. if (response.data.list !== null) {
  626. console.log('table数据', response.data.list)
  627. this.history.list = response.data.list
  628. this.history.pageNum = response.data.pageNum
  629. this.history.pageSize = response.data.pageSize
  630. this.history.total = response.data.total
  631. } else {
  632. this.history.list = []
  633. }
  634. setTimeout(() => {
  635. this.history.listLoading = false
  636. }, 100)
  637. })
  638. },
  639. // 行内删除
  640. handleRowDelete(row) {
  641. console.log(row, '点击了行删除')
  642. MessageBox.confirm('是否确认删除此信息?', {
  643. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  644. }).then(() => {
  645. this.selectList = []
  646. this.requestParam = {}
  647. this.requestParam.name = 'deletePremixplan'
  648. this.requestParam.parammaps = {}
  649. this.requestParam.parammaps.pastureid = row.pastureid
  650. this.requestParam.parammaps.id = row.id
  651. PostDataByName(this.requestParam).then(response => {
  652. if (response.msg === 'fail') {
  653. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  654. } else {
  655. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  656. this.getList()
  657. }
  658. })
  659. }).catch(() => {
  660. this.$message({ type: 'info', message: '已取消删除' })
  661. })
  662. },
  663. // 减少车次
  664. handleDelete() {
  665. if (this.selectList.length == 0) {
  666. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  667. } else {
  668. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  669. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  670. }).then(() => {
  671. console.log(this.selectList)
  672. this.requestParam.common = { 'returnmap': '0' }
  673. this.requestParam.data = []
  674. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  675. this.requestParam.data[0].children = []
  676. this.requestParam.data[0].children[0] = { 'name': 'deletePremixplan', 'type': 'e', 'parammaps': {
  677. id: '@insertSpotList.id',
  678. pastureid: '@insertSpotList.pastureid'
  679. }}
  680. ExecDataByConfig(this.requestParam).then(response => {
  681. console.log('删除保存发送参数', this.requestParam)
  682. if (response.msg === 'fail') {
  683. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  684. } else {
  685. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  686. this.getList()
  687. }
  688. })
  689. })
  690. }
  691. }
  692. }
  693. }
  694. </script>
  695. <style lang="scss" scoped>
  696. .search{clear: both;}
  697. .table{margin-top:10px;}
  698. /deep/ .el-time-panel__btn{
  699. height: 26px !important;
  700. }
  701. </style>