3184ff51d902268df21809d782990124ea29c8e6.svn-base 32 KB

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