b889fcbfe3f9d5da7872c730002dcae539a62b8f.svn-base 39 KB

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