541353afb468a677411538195e245d48cc9a0ec5.svn-base 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  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 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. }
  330. })
  331. },
  332. getList() {
  333. this.table.listLoading = true
  334. GetDataByName(this.table.getdataListParm).then(response => {
  335. console.log('table数据', response.data.list)
  336. if (response.data.list !== null) {
  337. for (let i = 0; i < response.data.list.length; i++) {
  338. this.$set(response.data.list[i], 'Edit', false) // 编辑
  339. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  340. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  341. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  342. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  343. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  344. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  345. }
  346. this.table.list = response.data.list
  347. this.table.pageNum = response.data.pageNum
  348. this.table.pageSize = response.data.pageSize
  349. this.table.total = response.data.total
  350. } else {
  351. this.table.list = []
  352. }
  353. setTimeout(() => {
  354. this.table.listLoading = false
  355. }, 100)
  356. })
  357. },
  358. // 配方名称
  359. changeformulaName(item, row) {
  360. row.ftname = this.formulaNameList.find(obj => obj.id == item).tname
  361. },
  362. // TMR编号
  363. changeTMRNumber(item, row) {
  364. row.tmrcode = this.TMRNumberList.find(obj => obj.id == item).tname
  365. row.maxweight = this.TMRNumberList.find(obj => obj.id == item).maxstirfeed
  366. },
  367. // 撒料计划车次跟随列表
  368. changeCarFollow(item, row) {
  369. console.log(item, row)
  370. if (item == '') {
  371. row.lppcode = ''
  372. } else {
  373. row.lppcode = this.carFollowList.find(obj => obj.id == item).lppcode
  374. this.$forceUpdate()
  375. }
  376. },
  377. // 班次
  378. changeTimes(item, row) {
  379. console.log(item, row)
  380. this.getCarFollowParm.parammaps.times = item
  381. this.getCarFollowList(row)
  382. this.$forceUpdate()
  383. },
  384. // 撒料计划车次跟随列表
  385. getCarFollowList(row) {
  386. GetDataByName(this.getCarFollowParm).then(response => {
  387. console.log('撒料计划车次跟随列表数据', response.data.list)
  388. if (response.data.list !== null) {
  389. this.carFollowList = response.data.list
  390. row.lppid = this.carFollowList[0].id
  391. row.lppcode = this.carFollowList[0].lppcode
  392. } else {
  393. this.carFollowList = []
  394. row.lppid = ''
  395. row.lppcode = ''
  396. }
  397. })
  398. },
  399. handleEnableChange() {
  400. console.log('点击了生效')
  401. },
  402. handleChangeOrder() {
  403. this.isOrder = false
  404. this.rowDrop()
  405. },
  406. saveChangeOrder() {
  407. // 保存顺序
  408. var sortArr = []
  409. for (let i = 0; i < this.table.list.length; i++) {
  410. var obj = {}
  411. obj.sort = i + 1
  412. obj.id = this.table.list[i].id
  413. obj.pastureid = this.table.list[i].pastureid
  414. sortArr.push(obj)
  415. }
  416. console.log(sortArr, 'sortArr=====')
  417. this.requestParam = {}
  418. this.requestParam.common = { 'returnmap': '0' }
  419. this.requestParam.data = []
  420. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortArr }}
  421. this.requestParam.data[0].children = []
  422. this.requestParam.data[0].children[0] = { 'name': 'updatePremixplanSort', 'type': 'e', 'parammaps': {
  423. id: '@insertSpotList.id',
  424. pastureid: '@insertSpotList.pastureid',
  425. sort: '@insertSpotList.sort'
  426. }}
  427. ExecDataByConfig(this.requestParam).then(response => {
  428. console.log('顺序切换保存发送参数', this.requestParam)
  429. if (response.msg === 'fail') {
  430. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  431. } else {
  432. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  433. this.getList()
  434. this.isOrder = true
  435. }
  436. })
  437. },
  438. cancelChangeOrder() {
  439. // 取消顺序
  440. this.getList()
  441. this.isOrder = true
  442. },
  443. // 行拖拽
  444. rowDrop() {
  445. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  446. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  447. const that = this
  448. var sortable = Sortable.create(tbody, {
  449. disabled: that.dropState,
  450. onChoose({ newIndex, oldIndex }) {
  451. if (that.dropState == true) {
  452. sortable.destroy()
  453. }
  454. },
  455. onEnd({ newIndex, oldIndex }) {
  456. const currRow = that.table.list.splice(oldIndex, 1)[0]
  457. that.table.list.splice(newIndex, 0, currRow)
  458. console.log('索引', newIndex)
  459. console.log('拖动数据', currRow)
  460. console.log('上', that.table.list[newIndex - 1])
  461. console.log('下', that.table.list[newIndex + 1])
  462. }
  463. })
  464. },
  465. // 模板新增
  466. handleCreate() {
  467. this.dropState = true
  468. console.log('点击了新增车次')
  469. // 编辑true/不可编辑false
  470. // 新增操true,编辑false,编辑保存false
  471. for (let i = 0; i < this.table.list.length; i++) {
  472. if (this.table.list[i].Edit === true) {
  473. console.log(123)
  474. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  475. return false
  476. }
  477. }
  478. var sort = 1
  479. if (this.table.list.length > 0) {
  480. sort = parseInt(this.table.list[this.table.list.length - 1].sort) + 1
  481. } else {
  482. sort = 1
  483. }
  484. 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': '' })
  485. },
  486. createData(row) {
  487. console.log('点击了新增保存', row)
  488. if (row.ptime == null || row.ptime == null) {
  489. row.ptime = ''
  490. }
  491. if (row.sort == '' && row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  492. this.$message({ type: 'error', message: '车次/配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  493. return false
  494. } else if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  495. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  496. return false
  497. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  498. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  499. return false
  500. } else if (row.times == '' && row.operateweight == '') {
  501. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  502. return false
  503. } else if (row.sort == '' || row.sort == 0) {
  504. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  505. return false
  506. } else if (row.ftid == '') {
  507. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  508. return false
  509. } else if (row.tmrid == '') {
  510. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  511. return false
  512. } else if (row.times == '') {
  513. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  514. return false
  515. } else if (row.operateweight == '') {
  516. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  517. return false
  518. }
  519. for (let i = 0; i < this.table.list.length; i++) {
  520. if (row.sort !== '') {
  521. if (row.sort == this.table.list[i].sort) {
  522. if (row.myId !== this.table.list[i].myId) {
  523. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  524. return false
  525. }
  526. }
  527. }
  528. }
  529. var isInteger = /^\d+$/
  530. if (row.sort !== '') {
  531. if (!isInteger.test(parseFloat(row.sort))) {
  532. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  533. return false
  534. }
  535. }
  536. this.isokDisable = true
  537. setTimeout(() => {
  538. this.isokDisable = false
  539. }, 1000)
  540. this.requestParam.name = 'insertPremixplan'
  541. this.requestParam.parammaps = row
  542. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  543. PostDataByName(this.requestParam).then(response => {
  544. console.log('新增保存发送参数', this.requestParam)
  545. if (response.msg !== 'fail') {
  546. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  547. this.getList()
  548. this.dropState = false
  549. } else {
  550. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  551. }
  552. })
  553. },
  554. createCancel(row) {
  555. console.log('点击了新增取消')
  556. this.dropState = false
  557. for (let i = 0; i < this.table.list.length; i++) {
  558. if (row.myId === this.table.list[i].myId) {
  559. var listIndex = this.table.list.indexOf(this.table.list[i])
  560. }
  561. if (listIndex > -1) {
  562. this.table.list.splice(listIndex, 1)
  563. return
  564. }
  565. }
  566. },
  567. // 模板编辑
  568. handleUpdate(row) {
  569. for (let i = 0; i < this.table.list.length; i++) {
  570. if (this.table.list[i].Edit == true) {
  571. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  572. return false
  573. }
  574. }
  575. // 编辑true,不可编辑false
  576. row.Edit = true
  577. row.NoEdit = false
  578. // 新增false,编辑false,编辑保存true
  579. row.isCreate = false
  580. row.isUpdate = false
  581. row.isUpdateSave = true
  582. // row.lppid = String(row.lppid)
  583. if (row.times == '第一班') {
  584. this.getCarFollowParm.parammaps.times = '1'
  585. row.times = '1'
  586. } else if (row.times == '第二班') {
  587. this.getCarFollowParm.parammaps.times = '2'
  588. row.times = '2'
  589. } else if (row.times == '第三班') {
  590. this.getCarFollowParm.parammaps.times = '3'
  591. row.times = '3'
  592. } else if (row.times == '第四班') {
  593. this.getCarFollowParm.parammaps.times = '4'
  594. row.times = '4'
  595. }
  596. GetDataByName(this.getCarFollowParm).then(response => {
  597. console.log('撒料计划车次跟随列表数据', response.data.list)
  598. if (response.data.list !== null) {
  599. this.carFollowList = response.data.list
  600. }
  601. })
  602. if (row.lppcode == undefined) {
  603. this.$set(row, 'lppid', '')
  604. }
  605. this.dropState = true
  606. },
  607. updateData(row) {
  608. console.log('点击了编辑保存', row)
  609. if (row.ptime == null || row.ptime == 'null') {
  610. row.ptime = ''
  611. }
  612. if (row.ftid == '' && row.tmrid == '' && row.times == '' && row.operateweight == '') {
  613. this.$message({ type: 'error', message: '配方名称/TMR编号/班次/混料重量不能为空', duration: 2000 })
  614. return false
  615. } else if (row.tmrid == '' && row.times == '' && row.operateweight == '') {
  616. this.$message({ type: 'error', message: 'TMR编号/班次/混料重量不能为空', duration: 2000 })
  617. return false
  618. } else if (row.times == '' && row.operateweight == '') {
  619. this.$message({ type: 'error', message: '班次/混料重量不能为空', duration: 2000 })
  620. return false
  621. } else if (row.ftid == '') {
  622. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  623. return false
  624. } else if (row.tmrid == '') {
  625. this.$message({ type: 'error', message: 'TMR编号不能为空', duration: 2000 })
  626. return false
  627. } else if (row.times == '') {
  628. this.$message({ type: 'error', message: '班次不能为空', duration: 2000 })
  629. return false
  630. } else if (row.operateweight == '') {
  631. this.$message({ type: 'error', message: '混料重量不能为空', duration: 2000 })
  632. return false
  633. }
  634. for (let i = 0; i < this.table.list.length; i++) {
  635. if (row.sort == this.table.list[i].sort) {
  636. if (row.id !== this.table.list[i].id) {
  637. this.$message({ type: 'error', message: '车次不可重复', duration: 2000 })
  638. return false
  639. }
  640. }
  641. }
  642. var isInteger = /^\d+$/
  643. if (row.sort !== '') {
  644. if (!isInteger.test(parseFloat(row.sort))) {
  645. this.$message({ type: 'error', message: '车次请输入整数', duration: 2000 })
  646. return false
  647. }
  648. }
  649. if (row.sort == '' || row.sort == 0) {
  650. this.$message({ type: 'error', message: '车次不能为空且大于0', duration: 2000 })
  651. return false
  652. }
  653. this.isokDisable = true
  654. setTimeout(() => {
  655. this.isokDisable = false
  656. }, 1000)
  657. this.requestParam.name = 'updatePremixplan'
  658. this.requestParam.parammaps = row
  659. PostDataByName(this.requestParam).then(response => {
  660. console.log('新增保存发送参数', this.requestParam)
  661. if (response.msg !== 'fail') {
  662. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  663. this.getList()
  664. this.dropState = false
  665. } else {
  666. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  667. }
  668. })
  669. },
  670. updateCancel(row) {
  671. console.log('点击了编辑取消')
  672. // 编辑false,不可编辑true
  673. row.Edit = false
  674. row.NoEdit = true
  675. // 新增false,编辑true,编辑保存false
  676. row.isCreate = false
  677. row.isUpdate = true
  678. row.isUpdateSave = false
  679. this.getList()
  680. this.dropState = false
  681. },
  682. handleSelect(val) {
  683. console.log('勾选数据', val)
  684. this.selectList = val
  685. },
  686. // 历史记录
  687. handleHistoryRecords() {
  688. console.log('点击了历史记录')
  689. this.dialogFull = false
  690. this.history.dialogStatus = 'history'
  691. this.history.dialogFormVisible = true
  692. this.getDateList()
  693. },
  694. // 历史时间
  695. getDateList() {
  696. GetDataByName(this.history.getdataDateParm).then(response => {
  697. console.log('table数据', response.data.list)
  698. if (response.data.list !== null) {
  699. this.history.getdataListParm.parammaps.date = response.data.list[0].maxdate
  700. this.getHistoryList()
  701. } else {
  702. this.history.getdataListParm.parammaps.date = ''
  703. }
  704. })
  705. },
  706. changeDate() {
  707. this.getHistoryList()
  708. },
  709. // 应用
  710. handleApplication() {
  711. console.log('点击了应用')
  712. MessageBox.confirm('是否确认将' + this.history.getdataListParm.parammaps.date + '的数据应用到当前?', {
  713. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  714. }).then(() => {
  715. this.requestParam.name = 'applyFPdate'
  716. this.requestParam.parammaps = {}
  717. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  718. this.requestParam.parammaps.date = this.history.getdataListParm.parammaps.date
  719. PostDataByName(this.requestParam).then(response => {
  720. if (response.msg === 'fail') {
  721. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  722. } else {
  723. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  724. this.getHistoryIsDisplay()
  725. this.getList()
  726. }
  727. })
  728. }).catch(() => {
  729. this.$message({ type: 'info', message: '已取消应用' })
  730. })
  731. },
  732. getHistoryList() {
  733. this.history.listLoading = true
  734. GetDataByName(this.history.getdataListParm).then(response => {
  735. console.log('table数据', response.data.list)
  736. if (response.data.list !== null) {
  737. console.log('table数据', response.data.list)
  738. this.history.list = response.data.list
  739. this.history.pageNum = response.data.pageNum
  740. this.history.pageSize = response.data.pageSize
  741. this.history.total = response.data.total
  742. } else {
  743. this.history.list = []
  744. }
  745. setTimeout(() => {
  746. this.history.listLoading = false
  747. }, 100)
  748. })
  749. },
  750. // 行内删除
  751. handleRowDelete(row) {
  752. console.log(row, '点击了行删除')
  753. MessageBox.confirm('是否确认删除此信息?', {
  754. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  755. }).then(() => {
  756. this.selectList = []
  757. this.requestParam = {}
  758. this.requestParam.name = 'deletePremixplan'
  759. this.requestParam.parammaps = {}
  760. this.requestParam.parammaps.pastureid = row.pastureid
  761. this.requestParam.parammaps.id = row.id
  762. PostDataByName(this.requestParam).then(response => {
  763. if (response.msg === 'fail') {
  764. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  765. } else {
  766. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  767. this.getList()
  768. }
  769. })
  770. }).catch(() => {
  771. this.$message({ type: 'info', message: '已取消删除' })
  772. })
  773. },
  774. // 减少车次
  775. handleDelete() {
  776. if (this.selectList.length == 0) {
  777. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  778. } else {
  779. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  780. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  781. }).then(() => {
  782. console.log(this.selectList)
  783. this.requestParam.common = { 'returnmap': '0' }
  784. this.requestParam.data = []
  785. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  786. this.requestParam.data[0].children = []
  787. this.requestParam.data[0].children[0] = { 'name': 'deletePremixplan', 'type': 'e', 'parammaps': {
  788. id: '@insertSpotList.id',
  789. pastureid: '@insertSpotList.pastureid'
  790. }}
  791. ExecDataByConfig(this.requestParam).then(response => {
  792. console.log('删除保存发送参数', this.requestParam)
  793. if (response.msg === 'fail') {
  794. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  795. } else {
  796. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  797. this.getList()
  798. }
  799. })
  800. })
  801. }
  802. },
  803. handleTakeEffect() {
  804. if (this.selectList.length == 0) {
  805. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  806. } else {
  807. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否生效?', {
  808. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  809. }).then(() => {
  810. for (let i = 0; i < this.selectList.length; i++) {
  811. // this.$set(this.selectList[i], 'enable', '1')
  812. this.selectList[i].enable = 1
  813. }
  814. console.log('生效', this.selectList)
  815. this.requestParam.common = { 'returnmap': '0' }
  816. this.requestParam.data = []
  817. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  818. this.requestParam.data[0].children = []
  819. this.requestParam.data[0].children[0] = { 'name': 'updatePremixplanEnable', 'type': 'e', 'parammaps': {
  820. enable: '@insertSpotList.enable',
  821. id: '@insertSpotList.id',
  822. pastureid: '@insertSpotList.pastureid'
  823. }}
  824. ExecDataByConfig(this.requestParam).then(response => {
  825. console.log('生效保存发送参数', this.requestParam)
  826. if (response.msg === 'fail') {
  827. this.$notify({ title: '生效失败', message: response.data, type: 'warning', duration: 2000 })
  828. } else {
  829. this.$notify({ title: '', message: '生效成功', type: 'success', duration: 2000 })
  830. this.getList()
  831. }
  832. })
  833. })
  834. }
  835. },
  836. handleDisable() {
  837. if (this.selectList.length == 0) {
  838. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  839. } else {
  840. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否禁用?', {
  841. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  842. }).then(() => {
  843. for (let i = 0; i < this.selectList.length; i++) {
  844. // this.$set(this.selectList[i], 'enable', '1')
  845. this.selectList[i].enable = 0
  846. }
  847. console.log('禁用', this.selectList)
  848. this.requestParam.common = { 'returnmap': '0' }
  849. this.requestParam.data = []
  850. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  851. this.requestParam.data[0].children = []
  852. this.requestParam.data[0].children[0] = { 'name': 'updatePremixplanEnable', 'type': 'e', 'parammaps': {
  853. enable: '@insertSpotList.enable',
  854. id: '@insertSpotList.id',
  855. pastureid: '@insertSpotList.pastureid'
  856. }}
  857. ExecDataByConfig(this.requestParam).then(response => {
  858. console.log('禁用保存发送参数', this.requestParam)
  859. if (response.msg === 'fail') {
  860. this.$notify({ title: '禁用失败', message: response.data, type: 'warning', duration: 2000 })
  861. } else {
  862. this.$notify({ title: '', message: '禁用成功', type: 'success', duration: 2000 })
  863. this.getList()
  864. }
  865. })
  866. })
  867. }
  868. }
  869. }
  870. }
  871. </script>
  872. <style lang="scss" scoped>
  873. .search{clear: both;}
  874. .table{margin-top:10px;}
  875. /deep/ .el-time-panel__btn{
  876. height: 26px !important;
  877. }
  878. </style>