index.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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="form_delete">减少车次</el-button>
  6. <el-button v-if="isOrder && isRoleEdit" icon="el-icon-sort" style="float: left;" class="success" @click="handleChangeOrder">更改顺序</el-button>
  7. <div v-else style="float: left;margin-left: 10px;">
  8. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
  9. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  10. </div>
  11. <el-button v-if="isRoleEdit" class="success" icon="el-icon-open" style="float: left;" @click="handleTakeEffect">生效</el-button>
  12. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-turn-off" style="float: left;" @click="handleDisable">禁用</el-button>
  13. <el-button class="import" style="float: right;" @click="handleHistoryRecords">历史记录</el-button>
  14. </div>
  15. <div class="search" />
  16. <div class="table">
  17. <el-table
  18. id="table"
  19. :key="table.tableKey"
  20. v-loading="table.listLoading"
  21. element-loading-text="给我一点时间"
  22. :data="table.list"
  23. border
  24. fit
  25. highlight-current-row
  26. style="width: 100%;"
  27. :row-style="rowStyle"
  28. :cell-style="cellStyle"
  29. class="elTable table-fixed"
  30. row-key="id"
  31. @selection-change="handleSelect"
  32. >
  33. <el-table-column type="selection" min-width="50" />
  34. <el-table-column label="车次" min-width="110px" align="center">
  35. <template slot-scope="scope">
  36. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  37. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.sort" type="number" style="width:80%;padding:10px 0;" />
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="配方名称" min-width="130px" align="center">
  41. <template slot-scope="scope">
  42. <span v-if="scope.row.NoEdit">{{ scope.row.ftname }}</span>
  43. <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)}">
  44. <el-option v-for="item in formulaNameList" :key="item.id" :label="item.tname" :value="item.id" />
  45. </el-select>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="TMR编号" prop="weight" min-width="130px" align="center">
  49. <template slot-scope="scope">
  50. <span v-if="scope.row.NoEdit">{{ scope.row.tmrcode }}</span>
  51. <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)}">
  52. <el-option v-for="item in TMRNumberList" :key="item.id" :label="item.eqcode" :value="item.id" />
  53. </el-select>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="班次" min-width="130px" align="center">
  57. <template slot-scope="scope">
  58. <span v-if="scope.row.NoEdit">{{ scope.row.times }}</span>
  59. <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)}">
  60. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  61. </el-select>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="撒料计划车次跟随" min-width="90px" align="center">
  65. <template slot-scope="scope">
  66. <span v-if="scope.row.NoEdit">{{ scope.row.lppcode }}</span>
  67. <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)}">
  68. <el-option v-for="item in carFollowList" :key="item.id" :label="item.lppcode" :value="item.id" />
  69. </el-select>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="生效" min-width="70px" align="center">
  73. <template slot-scope="scope">
  74. <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)" />
  75. </template>
  76. </el-table-column>
  77. <!-- <el-table-column label="时间" min-width="130px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.ptime }}</span>
  80. <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%;" />
  81. </template>
  82. </el-table-column> -->
  83. <el-table-column label="最大搅拌量(KG)" min-width="110px" align="center">
  84. <template slot-scope="scope">
  85. <span>{{ scope.row.maxweight }}</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="混料重量" min-width="110px" align="center">
  89. <template slot-scope="scope">
  90. <span v-if="scope.row.NoEdit">{{ scope.row.operateweight }}</span>
  91. <el-input v-if="scope.row.Edit" v-model="scope.row.operateweight" type="number" style="width:80%;padding:10px 0;" />
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  95. <template slot-scope="{row}">
  96. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  97. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  98. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  99. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  100. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  101. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  102. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  103. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  104. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. </div>
  109. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">共{{ table.total }}条</span>
  110. <!-- 历史记录 -->
  111. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="history.dialogFormVisible" :close-on-click-modal="false" width="90%">
  112. <template slot="title">
  113. <div class="avue-crud__dialog__header">
  114. <span class="el-dialog__title">
  115. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  116. {{ textMap[history.dialogStatus] }}
  117. </span>
  118. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  119. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  120. <svg-icon v-else icon-class="fullscreen" />
  121. </div>
  122. </div>
  123. </template>
  124. <div class="app-history">
  125. <div class="search">
  126. <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" />
  127. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  128. </div>
  129. <div class="table">
  130. <el-table
  131. :key="history.tableKey"
  132. v-loading="history.listLoading"
  133. element-loading-text="给我一点时间"
  134. :data="history.list"
  135. border
  136. fit
  137. highlight-current-row
  138. style="width: 100%;"
  139. :row-style="rowStyle"
  140. :cell-style="cellStyle"
  141. class="elTable table-fixed"
  142. >
  143. <el-table-column label="车次" min-width="130px" align="center">
  144. <template slot-scope="scope">
  145. <span>{{ scope.row.sort }}</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="配方名称" min-width="130px" align="center">
  149. <template slot-scope="scope">
  150. <span>{{ scope.row.ftname }}</span>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="TMR编号" prop="weight" min-width="130px" align="center">
  154. <template slot-scope="scope">
  155. <span>{{ scope.row.tmrcode }}</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.times }}</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.lppcode }}</span>
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="生效" min-width="130px" align="center">
  169. <template slot-scope="scope">
  170. <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)" />
  171. </template>
  172. </el-table-column>
  173. <el-table-column label="时间" min-width="180px" align="center">
  174. <template slot-scope="scope">
  175. <span>{{ scope.row.ptime }}</span>
  176. </template>
  177. </el-table-column>
  178. <el-table-column label="最大搅拌量(KG)" min-width="130px" align="center">
  179. <template slot-scope="scope">
  180. <span>{{ scope.row.maxweight }}</span>
  181. </template>
  182. </el-table-column>
  183. <el-table-column label="混料重量" min-width="130px" align="center">
  184. <template slot-scope="scope">
  185. <span>{{ scope.row.operateweight }}</span>
  186. </template>
  187. </el-table-column>
  188. </el-table>
  189. <pagination v-show="history.total>0" :total="history.total" :page.sync="history.getdataListParm.offset" :limit.sync="history.getdataListParm.pagecount" @pagination="getHistoryList" />
  190. </div>
  191. <div slot="footer" class="dialog-footer">
  192. <el-button class="cancelClose cancelClose1" @click="history.dialogFormVisible = false; ">关闭</el-button>
  193. </div>
  194. </div>
  195. </el-dialog>
  196. </div>
  197. </template>
  198. <script>
  199. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig, checkButtons } from '@/api/common'
  200. import Sortable from 'sortablejs'
  201. import Pagination from '@/components/Pagination'
  202. import Cookies from 'js-cookie'
  203. import { MessageBox } from 'element-ui'
  204. export default {
  205. name: 'PremixedPlan',
  206. components: { Pagination },
  207. data() {
  208. return {
  209. dialogFull: false,
  210. isRoleEdit: [],
  211. requestParams: [
  212. { name: 'getTMRYHList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  213. { name: 'getFTYHList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  214. ],
  215. formulaNameList: [], // 配方名称
  216. TMRNumberList: [], // TMR编号
  217. // 班次
  218. maxTime: {
  219. getMaxTimesParm: {
  220. name: 'getSysoptEnable',
  221. page: 1,
  222. offset: 1,
  223. pagecount: 1,
  224. returntype: 'Map',
  225. parammaps: {
  226. pastureid: Cookies.get('pastureid'),
  227. inforname: 'times'
  228. }
  229. }
  230. },
  231. frequencyList: [], // 班次
  232. getCarFollowParm: {
  233. name: 'getLPPCodeList',
  234. offset: 0,
  235. pagecount: 0,
  236. parammaps: {
  237. pastureid: Cookies.get('pastureid'),
  238. times: ''
  239. }
  240. },
  241. carFollowList: [], // 发料计划车次跟随
  242. table: {
  243. getdataListParm: {
  244. name: 'getPremixplanList',
  245. page: 1,
  246. offset: 1,
  247. pagecount: '',
  248. returntype: 'Map',
  249. parammaps: {
  250. pastureid: Cookies.get('pastureid')
  251. }
  252. },
  253. tableKey: 0,
  254. list: [],
  255. total: 0,
  256. listLoading: true
  257. },
  258. history: {
  259. dialogFormVisible: false,
  260. dialogStatus: '',
  261. temp: {},
  262. rules: {},
  263. tableKey: 0,
  264. list: [],
  265. total: 0,
  266. listLoading: true,
  267. getdataDateParm: {
  268. name: 'getPPMaxDate',
  269. page: 1,
  270. offset: 1,
  271. pagecount: 10,
  272. returntype: 'Map',
  273. parammaps: {
  274. pastureid: Cookies.get('pastureid')
  275. }
  276. },
  277. getdataListParm: {
  278. name: 'getPremixplanListDate',
  279. page: 1,
  280. offset: 1,
  281. pagecount: 10,
  282. returntype: 'Map',
  283. parammaps: {
  284. pastureid: Cookies.get('pastureid'),
  285. date: ''
  286. }
  287. }
  288. },
  289. textMap: {
  290. history: '历史记录'
  291. },
  292. selectList: [],
  293. isokDisable: false,
  294. requestParam: {},
  295. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  296. cellStyle: { padding: 0 + 'px' },
  297. dropState: false,
  298. isOrder: true
  299. }
  300. },
  301. created() {
  302. this.getButtons()
  303. this.getList()
  304. this.getDownList()
  305. this.getIsDisplay()
  306. },
  307. methods: {
  308. getButtons() {
  309. const Edit = 'PremixedPlan'
  310. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  311. this.isRoleEdit = isRoleEdit
  312. },
  313. getDownList() {
  314. GetDataByNames(this.requestParams).then(response => {
  315. this.TMRNumberList = response.data.getTMRYHList.list
  316. this.formulaNameList = response.data.getFTYHList.list
  317. })
  318. },
  319. getIsDisplay() {
  320. GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
  321. if (response.data.list[0].inforvalue == 1) {
  322. this.frequencyList = [{ id: '1', name: '第一班' }]
  323. } else if (response.data.list[0].inforvalue == 2) {
  324. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
  325. } else if (response.data.list[0].inforvalue == 3) {
  326. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  327. } else if (response.data.list[0].inforvalue == 4) {
  328. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  329. } else if (response.data.list[0].inforvalue == 5) {
  330. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }, { id: '5', name: '第五班' }]
  331. } else if (response.data.list[0].inforvalue == 6) {
  332. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }, { id: '5', name: '第五班' }, { id: '6', name: '第六班' }]
  333. }
  334. })
  335. },
  336. getList() {
  337. this.table.listLoading = true
  338. GetDataByName(this.table.getdataListParm).then(response => {
  339. console.log('table数据', response.data.list)
  340. if (response.data.list !== null) {
  341. for (let i = 0; i < response.data.list.length; i++) {
  342. this.$set(response.data.list[i], 'Edit', false) // 编辑
  343. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  344. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  345. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  346. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  347. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  348. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  349. }
  350. this.table.list = response.data.list
  351. this.table.pageNum = response.data.pageNum
  352. this.table.pageSize = response.data.pageSize
  353. this.table.total = response.data.total
  354. } else {
  355. this.table.list = []
  356. }
  357. setTimeout(() => {
  358. this.table.listLoading = false
  359. }, 100)
  360. })
  361. },
  362. // 配方名称
  363. changeformulaName(item, row) {
  364. row.ftname = this.formulaNameList.find(obj => obj.id == item).tname
  365. },
  366. // TMR编号
  367. changeTMRNumber(item, row) {
  368. row.tmrcode = this.TMRNumberList.find(obj => obj.id == item).tname
  369. row.maxweight = this.TMRNumberList.find(obj => obj.id == item).maxstirfeed
  370. },
  371. // 撒料计划车次跟随列表
  372. changeCarFollow(item, row) {
  373. console.log(item, row)
  374. if (item == '') {
  375. row.lppcode = ''
  376. } else {
  377. row.lppcode = this.carFollowList.find(obj => obj.id == item).lppcode
  378. this.$forceUpdate()
  379. }
  380. },
  381. // 班次
  382. changeTimes(item, row) {
  383. console.log(item, row)
  384. this.getCarFollowParm.parammaps.times = item
  385. this.getCarFollowList(row)
  386. this.$forceUpdate()
  387. },
  388. // 撒料计划车次跟随列表
  389. getCarFollowList(row) {
  390. GetDataByName(this.getCarFollowParm).then(response => {
  391. console.log('撒料计划车次跟随列表数据', response.data.list)
  392. if (response.data.list !== null) {
  393. this.carFollowList = response.data.list
  394. row.lppid = this.carFollowList[0].id
  395. row.lppcode = this.carFollowList[0].lppcode
  396. } else {
  397. this.carFollowList = []
  398. row.lppid = ''
  399. row.lppcode = ''
  400. }
  401. })
  402. },
  403. handleEnableChange() {
  404. console.log('点击了生效')
  405. },
  406. handleChangeOrder() {
  407. this.isOrder = false
  408. this.rowDrop()
  409. },
  410. saveChangeOrder() {
  411. // 保存顺序
  412. var sortArr = []
  413. for (let i = 0; i < this.table.list.length; i++) {
  414. var obj = {}
  415. obj.sort = i + 1
  416. obj.id = this.table.list[i].id
  417. obj.pastureid = this.table.list[i].pastureid
  418. sortArr.push(obj)
  419. }
  420. console.log(sortArr, 'sortArr=====')
  421. this.requestParam = {}
  422. this.requestParam.common = { 'returnmap': '0' }
  423. this.requestParam.data = []
  424. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortArr }}
  425. this.requestParam.data[0].children = []
  426. this.requestParam.data[0].children[0] = { 'name': 'updatePremixplanSort', 'type': 'e', 'parammaps': {
  427. id: '@insertSpotList.id',
  428. pastureid: '@insertSpotList.pastureid',
  429. sort: '@insertSpotList.sort'
  430. }}
  431. ExecDataByConfig(this.requestParam).then(response => {
  432. console.log('顺序切换保存发送参数', this.requestParam)
  433. if (response.msg === 'fail') {
  434. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  435. } else {
  436. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  437. this.getList()
  438. this.isOrder = true
  439. }
  440. })
  441. },
  442. cancelChangeOrder() {
  443. // 取消顺序
  444. this.getList()
  445. this.isOrder = true
  446. },
  447. // 行拖拽
  448. rowDrop() {
  449. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  450. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  451. const that = this
  452. var sortable = Sortable.create(tbody, {
  453. disabled: that.dropState,
  454. onChoose({ newIndex, oldIndex }) {
  455. if (that.dropState == true) {
  456. sortable.destroy()
  457. }
  458. },
  459. onEnd({ newIndex, oldIndex }) {
  460. const currRow = that.table.list.splice(oldIndex, 1)[0]
  461. that.table.list.splice(newIndex, 0, currRow)
  462. console.log('索引', newIndex)
  463. console.log('拖动数据', currRow)
  464. console.log('上', that.table.list[newIndex - 1])
  465. console.log('下', that.table.list[newIndex + 1])
  466. }
  467. })
  468. },
  469. // 模板新增
  470. handleCreate() {
  471. this.dropState = true
  472. console.log('点击了新增车次')
  473. // 编辑true/不可编辑false
  474. // 新增操true,编辑false,编辑保存false
  475. for (let i = 0; i < this.table.list.length; i++) {
  476. if (this.table.list[i].Edit === true) {
  477. console.log(123)
  478. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  479. return false
  480. }
  481. }
  482. var sort = 1
  483. if (this.table.list.length > 0) {
  484. sort = parseInt(this.table.list[this.table.list.length - 1].sort) + 1
  485. } else {
  486. sort = 1
  487. }
  488. 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': '' })
  489. },
  490. createData(row) {
  491. console.log('点击了新增保存', row)
  492. if (row.ptime == null || row.ptime == null) {
  493. row.ptime = ''
  494. }
  495. if (row.sort == '' && row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  496. this.$message({ type: 'error', message: '车次/配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  497. return false
  498. } else if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  499. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  500. return false
  501. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  502. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  503. return false
  504. } else if (row.times == '' && row.operateweight == '') {
  505. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  506. return false
  507. } else if (row.sort == '' || row.sort == 0) {
  508. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  509. return false
  510. } else if (row.ftid == '') {
  511. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  512. return false
  513. } else if (row.tmrid == '') {
  514. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  515. return false
  516. } else if (row.times == '') {
  517. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  518. return false
  519. } else if (row.operateweight == '') {
  520. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  521. return false
  522. }
  523. for (let i = 0; i < this.table.list.length; i++) {
  524. if (row.sort !== '') {
  525. if (row.sort == this.table.list[i].sort) {
  526. if (row.myId !== this.table.list[i].myId) {
  527. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  528. return false
  529. }
  530. }
  531. }
  532. }
  533. var isInteger = /^\d+$/
  534. if (row.sort !== '') {
  535. if (!isInteger.test(parseFloat(row.sort))) {
  536. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  537. return false
  538. }
  539. }
  540. this.isokDisable = true
  541. setTimeout(() => {
  542. this.isokDisable = false
  543. }, 1000)
  544. this.requestParam.name = 'insertPremixplan'
  545. this.requestParam.parammaps = row
  546. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  547. PostDataByName(this.requestParam).then(response => {
  548. console.log('新增保存发送参数', this.requestParam)
  549. if (response.msg !== 'fail') {
  550. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  551. this.getList()
  552. this.dropState = false
  553. } else {
  554. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  555. }
  556. })
  557. },
  558. createCancel(row) {
  559. console.log('点击了新增取消')
  560. this.dropState = false
  561. for (let i = 0; i < this.table.list.length; i++) {
  562. if (row.myId === this.table.list[i].myId) {
  563. var listIndex = this.table.list.indexOf(this.table.list[i])
  564. }
  565. if (listIndex > -1) {
  566. this.table.list.splice(listIndex, 1)
  567. return
  568. }
  569. }
  570. },
  571. // 模板编辑
  572. handleUpdate(row) {
  573. for (let i = 0; i < this.table.list.length; i++) {
  574. if (this.table.list[i].Edit == true) {
  575. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  576. return false
  577. }
  578. }
  579. // 编辑true,不可编辑false
  580. row.Edit = true
  581. row.NoEdit = false
  582. // 新增false,编辑false,编辑保存true
  583. row.isCreate = false
  584. row.isUpdate = false
  585. row.isUpdateSave = true
  586. // row.lppid = String(row.lppid)
  587. if (row.times == '第一班') {
  588. this.getCarFollowParm.parammaps.times = '1'
  589. row.times = '1'
  590. } else if (row.times == '第二班') {
  591. this.getCarFollowParm.parammaps.times = '2'
  592. row.times = '2'
  593. } else if (row.times == '第三班') {
  594. this.getCarFollowParm.parammaps.times = '3'
  595. row.times = '3'
  596. } else if (row.times == '第四班') {
  597. this.getCarFollowParm.parammaps.times = '4'
  598. row.times = '4'
  599. }
  600. GetDataByName(this.getCarFollowParm).then(response => {
  601. console.log('撒料计划车次跟随列表数据', response.data.list)
  602. if (response.data.list !== null) {
  603. this.carFollowList = response.data.list
  604. }
  605. })
  606. if (row.lppcode == undefined) {
  607. this.$set(row, 'lppid', '')
  608. }
  609. this.dropState = true
  610. },
  611. updateData(row) {
  612. console.log('点击了编辑保存', row)
  613. if (row.ptime == null || row.ptime == 'null') {
  614. row.ptime = ''
  615. }
  616. if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  617. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  618. return false
  619. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  620. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  621. return false
  622. } else if (row.times == '' && row.operateweight == '') {
  623. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  624. return false
  625. } else if (row.ftid == '') {
  626. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  627. return false
  628. } else if (row.tmrid == '') {
  629. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  630. return false
  631. } else if (row.times == '') {
  632. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  633. return false
  634. } else if (row.operateweight == '') {
  635. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  636. return false
  637. }
  638. for (let i = 0; i < this.table.list.length; i++) {
  639. if (row.sort == this.table.list[i].sort) {
  640. if (row.id !== this.table.list[i].id) {
  641. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  642. return false
  643. }
  644. }
  645. }
  646. var isInteger = /^\d+$/
  647. if (row.sort !== '') {
  648. if (!isInteger.test(parseFloat(row.sort))) {
  649. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  650. return false
  651. }
  652. }
  653. if (row.sort == '' || row.sort == 0) {
  654. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  655. return false
  656. }
  657. this.isokDisable = true
  658. setTimeout(() => {
  659. this.isokDisable = false
  660. }, 1000)
  661. this.requestParam.name = 'updatePremixplan'
  662. this.requestParam.parammaps = row
  663. PostDataByName(this.requestParam).then(response => {
  664. console.log('新增保存发送参数', this.requestParam)
  665. if (response.msg !== 'fail') {
  666. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  667. this.getList()
  668. this.dropState = false
  669. } else {
  670. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  671. }
  672. })
  673. },
  674. updateCancel(row) {
  675. console.log('点击了编辑取消')
  676. // 编辑false,不可编辑true
  677. row.Edit = false
  678. row.NoEdit = true
  679. // 新增false,编辑true,编辑保存false
  680. row.isCreate = false
  681. row.isUpdate = true
  682. row.isUpdateSave = false
  683. this.getList()
  684. this.dropState = false
  685. },
  686. handleSelect(val) {
  687. console.log('勾选数据', val)
  688. this.selectList = val
  689. },
  690. // 历史记录
  691. handleHistoryRecords() {
  692. console.log('点击了历史记录')
  693. this.dialogFull = false
  694. this.history.dialogStatus = 'history'
  695. this.history.dialogFormVisible = true
  696. this.getDateList()
  697. },
  698. // 历史时间
  699. getDateList() {
  700. GetDataByName(this.history.getdataDateParm).then(response => {
  701. console.log('table数据', response.data.list)
  702. if (response.data.list !== null) {
  703. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  704. this.getHistoryList()
  705. } else {
  706. this.history.getdataListParm.parammaps.date = ''
  707. }
  708. })
  709. },
  710. changeDate() {
  711. this.getHistoryList()
  712. },
  713. // 应用
  714. handleApplication() {
  715. console.log('点击了应用')
  716. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  717. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  718. }).then(() => {
  719. this.requestParam.name = 'applyFPdate'
  720. this.requestParam.parammaps = {}
  721. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  722. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  723. PostDataByName(this.requestParam).then(response => {
  724. if (response.msg === 'fail') {
  725. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  726. } else {
  727. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  728. this.getHistoryIsDisplay()
  729. this.getList()
  730. }
  731. })
  732. }).catch(() => {
  733. this.$message({ type: 'info', message: '已取消应用' })
  734. })
  735. },
  736. getHistoryList() {
  737. this.history.listLoading = true
  738. GetDataByName(this.history.getdataListParm).then(response => {
  739. console.log('table数据', response.data.list)
  740. if (response.data.list !== null) {
  741. console.log('table数据', response.data.list)
  742. this.history.list = response.data.list
  743. this.history.pageNum = response.data.pageNum
  744. this.history.pageSize = response.data.pageSize
  745. this.history.total = response.data.total
  746. } else {
  747. this.history.list = []
  748. }
  749. setTimeout(() => {
  750. this.history.listLoading = false
  751. }, 100)
  752. })
  753. },
  754. // 行内删除
  755. handleRowDelete(row) {
  756. console.log(row, '点击了行删除')
  757. MessageBox.confirm('是否确认删除此信息?', {
  758. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  759. }).then(() => {
  760. this.selectList = []
  761. this.requestParam = {}
  762. this.requestParam.name = 'deletePremixplan'
  763. this.requestParam.parammaps = {}
  764. this.requestParam.parammaps.pastureid = row.pastureid
  765. this.requestParam.parammaps.id = row.id
  766. PostDataByName(this.requestParam).then(response => {
  767. if (response.msg === 'fail') {
  768. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  769. } else {
  770. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  771. this.getList()
  772. }
  773. })
  774. }).catch(() => {
  775. this.$message({ type: 'info', message: '已取消删除' })
  776. })
  777. },
  778. // 减少车次
  779. form_delete() {
  780. if (this.selectList.length == 0) {
  781. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  782. } else {
  783. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  784. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  785. }).then(() => {
  786. console.log(this.selectList)
  787. this.requestParam.common = { 'returnmap': '0' }
  788. this.requestParam.data = []
  789. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  790. this.requestParam.data[0].children = []
  791. this.requestParam.data[0].children[0] = { 'name': 'deletePremixplan', 'type': 'e', 'parammaps': {
  792. id: '@insertSpotList.id',
  793. pastureid: '@insertSpotList.pastureid'
  794. }}
  795. ExecDataByConfig(this.requestParam).then(response => {
  796. console.log('删除保存发送参数', this.requestParam)
  797. if (response.msg === 'fail') {
  798. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  799. } else {
  800. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  801. this.getList()
  802. }
  803. })
  804. })
  805. }
  806. },
  807. handleTakeEffect() {
  808. if (this.selectList.length == 0) {
  809. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  810. } else {
  811. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否生效?', {
  812. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  813. }).then(() => {
  814. for (let i = 0; i < this.selectList.length; i++) {
  815. // this.$set(this.selectList[i], 'enable', '1')
  816. this.selectList[i].enable = 1
  817. }
  818. console.log('生效', this.selectList)
  819. this.requestParam.common = { 'returnmap': '0' }
  820. this.requestParam.data = []
  821. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  822. this.requestParam.data[0].children = []
  823. this.requestParam.data[0].children[0] = { 'name': 'updatePremixplanEnable', 'type': 'e', 'parammaps': {
  824. enable: '@insertSpotList.enable',
  825. id: '@insertSpotList.id',
  826. pastureid: '@insertSpotList.pastureid'
  827. }}
  828. ExecDataByConfig(this.requestParam).then(response => {
  829. console.log('生效保存发送参数', this.requestParam)
  830. if (response.msg === 'fail') {
  831. this.$notify({ title: '生效失败', message: response.data, type: 'warning', duration: 2000 })
  832. } else {
  833. this.$notify({ title: '', message: '生效成功', type: 'success', duration: 2000 })
  834. this.getList()
  835. }
  836. })
  837. })
  838. }
  839. },
  840. handleDisable() {
  841. if (this.selectList.length == 0) {
  842. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  843. } else {
  844. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否禁用?', {
  845. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  846. }).then(() => {
  847. for (let i = 0; i < this.selectList.length; i++) {
  848. // this.$set(this.selectList[i], 'enable', '1')
  849. this.selectList[i].enable = 0
  850. }
  851. console.log('禁用', this.selectList)
  852. this.requestParam.common = { 'returnmap': '0' }
  853. this.requestParam.data = []
  854. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  855. this.requestParam.data[0].children = []
  856. this.requestParam.data[0].children[0] = { 'name': 'updatePremixplanEnable', 'type': 'e', 'parammaps': {
  857. enable: '@insertSpotList.enable',
  858. id: '@insertSpotList.id',
  859. pastureid: '@insertSpotList.pastureid'
  860. }}
  861. ExecDataByConfig(this.requestParam).then(response => {
  862. console.log('禁用保存发送参数', this.requestParam)
  863. if (response.msg === 'fail') {
  864. this.$notify({ title: '禁用失败', message: response.data, type: 'warning', duration: 2000 })
  865. } else {
  866. this.$notify({ title: '', message: '禁用成功', type: 'success', duration: 2000 })
  867. this.getList()
  868. }
  869. })
  870. })
  871. }
  872. }
  873. }
  874. }
  875. </script>
  876. <style lang="scss" scoped>
  877. .search{clear: both;}
  878. /deep/ .el-time-panel__btn{
  879. height: 26px !important;
  880. }
  881. </style>