7ba8d55da08e0bd4832d7556296fcd33bc6d469f.svn-base 31 KB

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