bf6bc5211e4c3d96a79911bc30fa6a203ca9f86b.svn-base 31 KB

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