fa5a45799546ac2412d8a87e74626ea967b1a002.svn-base 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  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="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="150" 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: '',
  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. console.log(item, row)
  342. if (item == '') {
  343. row.lppcode = ''
  344. } else {
  345. row.lppcode = this.carFollowList.find(obj => obj.id == item).lppcode
  346. this.$forceUpdate()
  347. }
  348. },
  349. // 班次
  350. changeTimes(item, row) {
  351. console.log(item, row)
  352. this.getCarFollowParm.parammaps.times = item
  353. this.getCarFollowList(row)
  354. this.$forceUpdate()
  355. },
  356. // 撒料计划车次跟随列表
  357. getCarFollowList(row) {
  358. GetDataByName(this.getCarFollowParm).then(response => {
  359. console.log('撒料计划车次跟随列表数据', response.data.list)
  360. if (response.data.list !== null) {
  361. this.carFollowList = response.data.list
  362. row.lppid = this.carFollowList[0].id
  363. row.lppcode = this.carFollowList[0].lppcode
  364. }
  365. })
  366. },
  367. handleEnableChange() {
  368. console.log('点击了生效')
  369. },
  370. // 行拖拽
  371. rowDrop() {
  372. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  373. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  374. const that = this
  375. var sortable = Sortable.create(tbody, {
  376. disabled: that.dropState,
  377. onChoose({ newIndex, oldIndex }) {
  378. if (that.dropState == true) {
  379. sortable.destroy()
  380. }
  381. },
  382. onEnd({ newIndex, oldIndex }) {
  383. const currRow = that.table.list.splice(oldIndex, 1)[0]
  384. that.table.list.splice(newIndex, 0, currRow)
  385. console.log('索引', newIndex)
  386. console.log('拖动数据', currRow)
  387. console.log('上', that.table.list[newIndex - 1])
  388. console.log('下', that.table.list[newIndex + 1])
  389. }
  390. })
  391. },
  392. // 模板新增
  393. handleCreate() {
  394. this.dropState = true
  395. console.log('点击了新增车次')
  396. // 编辑true/不可编辑false
  397. // 新增操true,编辑false,编辑保存false
  398. for (let i = 0; i < this.table.list.length; i++) {
  399. if (this.table.list[i].Edit === true) {
  400. console.log(123)
  401. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  402. return false
  403. }
  404. }
  405. var sort = 1
  406. if (this.table.list.length > 0) {
  407. sort = parseInt(this.table.list[this.table.list.length - 1].sort) + 1
  408. } else {
  409. sort = 1
  410. }
  411. 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': '' })
  412. },
  413. createData(row) {
  414. console.log('点击了新增保存', row)
  415. if (row.ptime == null || row.ptime == null) {
  416. row.ptime = ''
  417. }
  418. if (row.sort == '' && row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  419. this.$message({ type: 'error', message: '车次/配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  420. return false
  421. } else if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  422. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  423. return false
  424. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  425. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  426. return false
  427. } else if (row.times == '' && row.operateweight == '') {
  428. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  429. return false
  430. } else if (row.sort == '' || row.sort == 0) {
  431. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  432. return false
  433. } else if (row.ftid == '') {
  434. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  435. return false
  436. } else if (row.tmrid == '') {
  437. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  438. return false
  439. } else if (row.times == '') {
  440. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  441. return false
  442. } else if (row.operateweight == '') {
  443. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  444. return false
  445. }
  446. for (let i = 0; i < this.table.list.length; i++) {
  447. if (row.sort !== '') {
  448. if (row.sort == this.table.list[i].sort) {
  449. if (row.myId !== this.table.list[i].myId) {
  450. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  451. return false
  452. }
  453. }
  454. }
  455. }
  456. var isInteger = /^\d+$/
  457. if (row.sort !== '') {
  458. if (!isInteger.test(parseFloat(row.sort))) {
  459. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  460. return false
  461. }
  462. }
  463. this.isokDisable = true
  464. setTimeout(() => {
  465. this.isokDisable = false
  466. }, 1000)
  467. this.requestParam.name = 'insertPremixplan'
  468. this.requestParam.parammaps = row
  469. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  470. PostDataByName(this.requestParam).then(response => {
  471. console.log('新增保存发送参数', this.requestParam)
  472. if (response.msg !== 'fail') {
  473. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  474. this.getList()
  475. this.dropState = false
  476. } else {
  477. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  478. }
  479. })
  480. },
  481. createCancel(row) {
  482. console.log('点击了新增取消')
  483. this.dropState = false
  484. for (let i = 0; i < this.table.list.length; i++) {
  485. if (row.myId === this.table.list[i].myId) {
  486. var listIndex = this.table.list.indexOf(this.table.list[i])
  487. }
  488. if (listIndex > -1) {
  489. this.table.list.splice(listIndex, 1)
  490. return
  491. }
  492. }
  493. },
  494. // 模板编辑
  495. handleUpdate(row) {
  496. for (let i = 0; i < this.table.list.length; i++) {
  497. if (this.table.list[i].Edit == true) {
  498. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  499. return false
  500. }
  501. }
  502. // 编辑true,不可编辑false
  503. row.Edit = true
  504. row.NoEdit = false
  505. // 新增false,编辑false,编辑保存true
  506. row.isCreate = false
  507. row.isUpdate = false
  508. row.isUpdateSave = true
  509. // row.lppid = String(row.lppid)
  510. if (row.times == '第一班') {
  511. this.getCarFollowParm.parammaps.times = '1'
  512. row.times = '1'
  513. } else if (row.times == '第二班') {
  514. this.getCarFollowParm.parammaps.times = '2'
  515. row.times = '2'
  516. } else if (row.times == '第三班') {
  517. this.getCarFollowParm.parammaps.times = '3'
  518. row.times = '3'
  519. } else if (row.times == '第四班') {
  520. this.getCarFollowParm.parammaps.times = '4'
  521. row.times = '4'
  522. }
  523. GetDataByName(this.getCarFollowParm).then(response => {
  524. console.log('撒料计划车次跟随列表数据', response.data.list)
  525. if (response.data.list !== null) {
  526. this.carFollowList = response.data.list
  527. }
  528. })
  529. this.dropState = true
  530. },
  531. updateData(row) {
  532. console.log('点击了编辑保存', row)
  533. if (row.ptime == null || row.ptime == 'null') {
  534. row.ptime = ''
  535. }
  536. if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  537. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  538. return false
  539. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  540. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  541. return false
  542. } else if (row.times == '' && row.operateweight == '') {
  543. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  544. return false
  545. } else if (row.ftid == '') {
  546. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  547. return false
  548. } else if (row.tmrid == '') {
  549. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  550. return false
  551. } else if (row.times == '') {
  552. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  553. return false
  554. } else if (row.operateweight == '') {
  555. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  556. return false
  557. }
  558. for (let i = 0; i < this.table.list.length; i++) {
  559. if (row.sort == this.table.list[i].sort) {
  560. if (row.id !== this.table.list[i].id) {
  561. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  562. return false
  563. }
  564. }
  565. }
  566. var isInteger = /^\d+$/
  567. if (row.sort !== '') {
  568. if (!isInteger.test(parseFloat(row.sort))) {
  569. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  570. return false
  571. }
  572. }
  573. if (row.sort == '' || row.sort == 0) {
  574. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  575. return false
  576. }
  577. this.isokDisable = true
  578. setTimeout(() => {
  579. this.isokDisable = false
  580. }, 1000)
  581. this.requestParam.name = 'updatePremixplan'
  582. this.requestParam.parammaps = row
  583. PostDataByName(this.requestParam).then(response => {
  584. console.log('新增保存发送参数', this.requestParam)
  585. if (response.msg !== 'fail') {
  586. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  587. this.getList()
  588. this.dropState = false
  589. } else {
  590. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  591. }
  592. })
  593. },
  594. updateCancel(row) {
  595. console.log('点击了编辑取消')
  596. // 编辑false,不可编辑true
  597. row.Edit = false
  598. row.NoEdit = true
  599. // 新增false,编辑true,编辑保存false
  600. row.isCreate = false
  601. row.isUpdate = true
  602. row.isUpdateSave = false
  603. this.getList()
  604. this.dropState = false
  605. },
  606. handleSelect(val) {
  607. console.log('勾选数据', val)
  608. this.selectList = val
  609. },
  610. // 历史记录
  611. handleHistoryRecords() {
  612. console.log('点击了历史记录')
  613. this.history.dialogStatus = 'history'
  614. this.history.dialogFormVisible = true
  615. this.getDateList()
  616. },
  617. // 历史时间
  618. getDateList() {
  619. GetDataByName(this.history.getdataDateParm).then(response => {
  620. console.log('table数据', response.data.list)
  621. if (response.data.list !== null) {
  622. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  623. this.getHistoryList()
  624. } else {
  625. this.history.getdataListParm.parammaps.date = ''
  626. }
  627. })
  628. },
  629. changeDate() {
  630. this.getHistoryList()
  631. },
  632. // 应用
  633. handleApplication() {
  634. console.log('点击了应用')
  635. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  636. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  637. }).then(() => {
  638. this.requestParam.name = 'applyFPdate'
  639. this.requestParam.parammaps = {}
  640. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  641. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  642. PostDataByName(this.requestParam).then(response => {
  643. if (response.msg === 'fail') {
  644. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  645. } else {
  646. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  647. this.getHistoryIsDisplay()
  648. this.getList()
  649. }
  650. })
  651. }).catch(() => {
  652. this.$message({ type: 'info', message: '已取消应用' })
  653. })
  654. },
  655. getHistoryList() {
  656. this.history.listLoading = true
  657. GetDataByName(this.history.getdataListParm).then(response => {
  658. console.log('table数据', response.data.list)
  659. if (response.data.list !== null) {
  660. console.log('table数据', response.data.list)
  661. this.history.list = response.data.list
  662. this.history.pageNum = response.data.pageNum
  663. this.history.pageSize = response.data.pageSize
  664. this.history.total = response.data.total
  665. } else {
  666. this.history.list = []
  667. }
  668. setTimeout(() => {
  669. this.history.listLoading = false
  670. }, 100)
  671. })
  672. },
  673. // 行内删除
  674. handleRowDelete(row) {
  675. console.log(row, '点击了行删除')
  676. MessageBox.confirm('是否确认删除此信息?', {
  677. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  678. }).then(() => {
  679. this.selectList = []
  680. this.requestParam = {}
  681. this.requestParam.name = 'deletePremixplan'
  682. this.requestParam.parammaps = {}
  683. this.requestParam.parammaps.pastureid = row.pastureid
  684. this.requestParam.parammaps.id = row.id
  685. PostDataByName(this.requestParam).then(response => {
  686. if (response.msg === 'fail') {
  687. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  688. } else {
  689. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  690. this.getList()
  691. }
  692. })
  693. }).catch(() => {
  694. this.$message({ type: 'info', message: '已取消删除' })
  695. })
  696. },
  697. // 减少车次
  698. handleDelete() {
  699. if (this.selectList.length == 0) {
  700. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  701. } else {
  702. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  703. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  704. }).then(() => {
  705. console.log(this.selectList)
  706. this.requestParam.common = { 'returnmap': '0' }
  707. this.requestParam.data = []
  708. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  709. this.requestParam.data[0].children = []
  710. this.requestParam.data[0].children[0] = { 'name': 'deletePremixplan', 'type': 'e', 'parammaps': {
  711. id: '@insertSpotList.id',
  712. pastureid: '@insertSpotList.pastureid'
  713. }}
  714. ExecDataByConfig(this.requestParam).then(response => {
  715. console.log('删除保存发送参数', this.requestParam)
  716. if (response.msg === 'fail') {
  717. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  718. } else {
  719. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  720. this.getList()
  721. }
  722. })
  723. })
  724. }
  725. }
  726. }
  727. }
  728. </script>
  729. <style lang="scss" scoped>
  730. .search{clear: both;}
  731. .table{margin-top:10px;}
  732. /deep/ .el-time-panel__btn{
  733. height: 26px !important;
  734. }
  735. </style>