index.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-date-picker
  5. v-model="table.getdataListParm.parammaps.inputDatetime"
  6. class="inputDatetime filter-item"
  7. type="daterange"
  8. range-separator="至"
  9. start-placeholder="开始日期"
  10. end-placeholder="结束日期"
  11. style="width: 250px"
  12. />
  13. <!-- <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  14. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  15. <el-select v-model="table.getdataListParm.parammaps.ftid" filterable placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  16. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  17. </el-select>
  18. <el-select v-model="record" filterable placeholder="记录" class="filter-item" style="width: 150px;" @change="changeRecord">
  19. <el-option v-for="item in recordList" :key="item.id" :label="item.name" :value="item.id" />
  20. </el-select>
  21. <el-select v-if="record== '1'" v-model="table.getdataListParm.parammaps.eqcode" filterable placeholder="TMR编号" class="filter-item" style="width: 120px;" clearable>
  22. <el-option v-for="item in TMRNumberList" :key="item.id" :label="item.tname" :value="item.eqcode" />
  23. </el-select> -->
  24. <el-button class="successBorder" @click="form_search">查询</el-button>
  25. <!-- <el-button class="successBorder" @click="handleRefresh">重置</el-button> -->
  26. </div>
  27. <div class="operation" v-if="record == '0'">
  28. <el-button
  29. v-if="isRoleEdit"
  30. icon="el-icon-plus"
  31. class="success"
  32. @click="handleCreate"
  33. >新增</el-button
  34. >
  35. <el-button
  36. v-if="isRoleEdit"
  37. icon="el-icon-delete"
  38. class="danger"
  39. @click="form_delete"
  40. >删除</el-button
  41. >
  42. <el-button
  43. v-if="isRoleEdit"
  44. class="success"
  45. icon="el-icon-upload2"
  46. @click="handleSAPUpload"
  47. >SAP上传</el-button
  48. >
  49. <!-- <el-button v-if="dataSynchronization.isDataSynchronization && isRoleEdit" class="success" @click="handleDataUpload">数据上传</el-button>
  50. <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  51. <el-button class="import" icon="el-icon-download" style="float: right;">导入</el-button>
  52. </el-upload>
  53. <el-dropdown style="float: right;margin-right: 10px;">
  54. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  55. <el-dropdown-menu slot="dropdown">
  56. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  57. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  58. </el-dropdown-menu>
  59. </el-dropdown> -->
  60. </div>
  61. <div class="operation" v-else>
  62. <el-button
  63. v-if="dataSynchronization.isDataSynchronization && isRoleEdit"
  64. class="success"
  65. @click="handleDataUpload"
  66. >数据上传</el-button
  67. >
  68. <el-button
  69. style="float: right; margin-right: 10px"
  70. class="export"
  71. icon="el-icon-upload2"
  72. @click="handleExport(3)"
  73. >导出</el-button
  74. >
  75. </div>
  76. <!-- 剩料使用 table -->
  77. <div class="table">
  78. <el-table
  79. :key="table.tableKey"
  80. v-loading="table.listLoading"
  81. element-loading-text="给我一点时间"
  82. :data="table.list"
  83. border
  84. fit
  85. highlight-current-row
  86. style="width: 100%"
  87. :row-style="rowStyle"
  88. :cell-style="cellStyle"
  89. class="elTable table-fixed"
  90. :header-cell-style="{ 'text-align': 'center' }"
  91. @selection-change="handleSelectionChange"
  92. :max-height="myHeight"
  93. >
  94. <el-table-column type="selection" align="left" width="50" />
  95. <el-table-column label="序号" align="left" type="index" width="50px">
  96. <template slot-scope="scope">
  97. <span>{{
  98. scope.$index + (table.pageNum - 1) * table.pageSize + 1
  99. }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column
  103. label="栏舍名称"
  104. min-width="120px"
  105. align="left"
  106. prop="barname"
  107. />
  108. <el-table-column
  109. label="配方名称"
  110. min-width="120px"
  111. align="left"
  112. prop="ftname"
  113. />
  114. <el-table-column
  115. label="剩料使用时间"
  116. min-width="150px"
  117. align="left"
  118. prop="date"
  119. />
  120. <el-table-column
  121. label="班次"
  122. min-width="90px"
  123. align="left"
  124. prop="timesstr"
  125. />
  126. <el-table-column
  127. label="替代方案"
  128. min-width="100px"
  129. align="left"
  130. prop="surplus"
  131. />
  132. <el-table-column
  133. label="替代重量(Kg)"
  134. min-width="100px"
  135. align="left"
  136. prop="weight"
  137. />
  138. <el-table-column
  139. label="操作"
  140. align="left"
  141. width="100"
  142. class-name="small-padding fixed-width"
  143. fixed="right"
  144. >
  145. <template slot-scope="{ row }">
  146. <!-- <el-button v-if="isRoleEdit" :disabled="row.emp == '设备采集'" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  147. <span v-if="isRoleEdit" class="centerSpan">|</span> -->
  148. <el-button
  149. v-if="isRoleEdit"
  150. :disabled="row.emp == '设备采集'"
  151. class="miniDanger"
  152. icon="el-icon-delete"
  153. @click="handleRowDelete(row)"
  154. />
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. <pagination
  159. v-show="table.total >= 0"
  160. :total="table.total"
  161. :page.sync="table.getdataListParm.offset"
  162. :limit.sync="table.getdataListParm.pagecount"
  163. @pagination="getList"
  164. />
  165. </div>
  166. <!-- 新增/编辑 -->
  167. <el-dialog
  168. :fullscreen="dialogFull"
  169. :visible.sync="create.dialogFormVisible"
  170. :close-on-click-modal="false"
  171. v-if="create.dialogFormVisible"
  172. width="40%"
  173. >
  174. <template slot="title">
  175. <div class="avue-crud__dialog__header">
  176. <span class="el-dialog__title">
  177. <span
  178. style="
  179. display: inline-block;
  180. width: 3px;
  181. height: 20px;
  182. margin-right: 5px;
  183. float: left;
  184. margin-top: 2px;
  185. "
  186. />
  187. {{ textMap[create.dialogStatus] }}
  188. </span>
  189. <div
  190. class="avue-crud__dialog__menu"
  191. @click="dialogFull ? (dialogFull = false) : (dialogFull = true)"
  192. >
  193. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  194. <svg-icon v-else icon-class="fullscreen" />
  195. </div>
  196. </div>
  197. </template>
  198. <div class="app-add">
  199. <el-form
  200. ref="temp"
  201. :rules="create.rules"
  202. :model="create.temp"
  203. label-position="right"
  204. label-width="135px"
  205. style="width: 90%; margin: 0 auto 50px"
  206. >
  207. <el-row v-if="create.dialogStatus == 'create'">
  208. <el-col :span="20">
  209. <el-form-item label="栏舍名称:" prop="barid">
  210. <el-select
  211. ref="ftid"
  212. v-model="create.temp.barid"
  213. :disabled="create.dialogStatus == 'update'"
  214. filterable
  215. placeholder="栏舍名称"
  216. class="filter-item"
  217. style="width: 100%"
  218. @change="changeBar"
  219. >
  220. <el-option
  221. v-for="item in houseNameList"
  222. :key="item.id"
  223. :label="item.bname"
  224. :value="item.id"
  225. />
  226. </el-select>
  227. </el-form-item>
  228. </el-col>
  229. </el-row>
  230. <el-row v-else>
  231. <el-col :span="20">
  232. <el-form-item label="栏舍名称:" prop="barname">
  233. <el-input
  234. ref="barname"
  235. v-model="create.temp.barname"
  236. disabled
  237. class="filter-item"
  238. placeholder=""
  239. />
  240. </el-form-item>
  241. </el-col>
  242. </el-row>
  243. <!-- TODO: -->
  244. <el-row>
  245. <el-col :span="20">
  246. <el-form-item label="配方名称:">
  247. <el-input
  248. v-model="create.temp.ftname"
  249. class="filter-item"
  250. placeholder="配方名称"
  251. disabled
  252. />
  253. </el-form-item>
  254. </el-col>
  255. </el-row>
  256. <el-row>
  257. <el-col :span="20">
  258. <el-form-item label="剩料使用时间:" prop="date">
  259. <el-date-picker
  260. v-model="create.temp.date"
  261. type="date"
  262. value-format="yyyy-MM-dd"
  263. style="width: 100%"
  264. :picker-options="pickerOptions"
  265. placeholder="剩料使用时间"
  266. >
  267. </el-date-picker>
  268. </el-form-item>
  269. </el-col>
  270. <el-col :span="20">
  271. <el-form-item label="班次:">
  272. <el-select
  273. ref="times"
  274. v-model="create.temp.times"
  275. filterable
  276. placeholder="班次"
  277. :disabled="create.dialogStatus == 'update'"
  278. class="filter-item"
  279. style="width: 100%"
  280. >
  281. <el-option
  282. v-for="item in frequencyList"
  283. :key="item.id"
  284. :label="item.name"
  285. :value="item.id"
  286. />
  287. </el-select>
  288. </el-form-item>
  289. </el-col>
  290. </el-row>
  291. <!-- -->
  292. <el-row>
  293. <el-col :span="20">
  294. <el-form-item label="替代方案:" prop="surplus">
  295. <el-select
  296. style="width: 100%"
  297. v-model="create.temp.surplus"
  298. filterable
  299. clearable
  300. placeholder="替代方案"
  301. class="filter-item"
  302. @change="handlegetSurplus"
  303. >
  304. <el-option
  305. v-for="item in tableData"
  306. :key="item.id"
  307. :label="item.surplus"
  308. :value="item.surplus"
  309. />
  310. </el-select>
  311. </el-form-item>
  312. </el-col>
  313. </el-row>
  314. <el-row>
  315. <el-col :span="20">
  316. <el-form-item label="替代重量(Kg):" prop="weight">
  317. <el-input
  318. ref="weight"
  319. v-model="create.temp.weight"
  320. class="filter-item"
  321. placeholder="替代重量"
  322. type="number"
  323. />
  324. </el-form-item>
  325. </el-col>
  326. </el-row>
  327. </el-form>
  328. <div slot="footer" class="dialog-footer">
  329. <el-button
  330. class="cancelClose"
  331. @click="
  332. create.dialogFormVisible = false;
  333. getList();
  334. "
  335. >关闭</el-button
  336. >
  337. <el-button
  338. v-if="
  339. create.dialogStatus === 'create' ||
  340. create.dialogStatus === 'update'
  341. "
  342. class="save"
  343. :disabled="isokDisable"
  344. @click="
  345. create.dialogStatus === 'create' ? createData() : updateData()
  346. "
  347. >确认</el-button
  348. >
  349. </div>
  350. </div>
  351. </el-dialog>
  352. <!-- sap上传 -->
  353. <el-dialog
  354. title="SAP上传"
  355. :destroy-on-close="true"
  356. :visible.sync="sapUpload.dialogFormVisible"
  357. :close-on-click-modal="false"
  358. width="40%"
  359. >
  360. <div class="sapUpload">
  361. <el-form
  362. ref="sapUpload"
  363. :rules="sapUpload.rules"
  364. :model="sapUpload.temp"
  365. label-position="right"
  366. label-width="100px"
  367. style="width: 100%; margin: 0 auto 50px"
  368. >
  369. <el-row>
  370. <el-col :span="24">
  371. <el-form-item label="时间:" prop="date">
  372. <el-date-picker
  373. v-model="sapUpload.temp.date"
  374. :clearable="false"
  375. class="filter-item"
  376. type="date"
  377. />
  378. </el-form-item>
  379. </el-col>
  380. </el-row>
  381. </el-form>
  382. <div slot="footer" class="dialog-footer" style="bottom: 20px">
  383. <el-button
  384. class="cancelClose"
  385. @click="
  386. sapUpload.dialogFormVisible = false;
  387. getList();
  388. "
  389. >取消</el-button
  390. >
  391. <el-button
  392. class="save"
  393. :disabled="isokDisable"
  394. @click="sapUploadData()"
  395. >确认</el-button
  396. >
  397. </div>
  398. </div>
  399. </el-dialog>
  400. </div>
  401. </template>
  402. <script>
  403. import {
  404. GetDataByName,
  405. PostDataByName,
  406. getSurplus,
  407. GetDataByNames,
  408. checkButtons,
  409. postJson2,
  410. postJson,
  411. } from "@/api/common";
  412. import Cookies from "js-cookie";
  413. import { parseTime, json2excel } from "@/utils/index.js";
  414. import Pagination from "@/components/Pagination";
  415. import { MessageBox } from "element-ui";
  416. import axios from "axios";
  417. import { getToken } from "@/utils/auth";
  418. export default {
  419. name: "MaterialRemainingRecord",
  420. components: { Pagination },
  421. data() {
  422. return {
  423. pickerOptions: {
  424. disabledDate(time) {
  425. return time.getTime() > Date.now() - 8.64e6; //如果没有后面的-8.64e6就是不可以选择今天的
  426. },
  427. },
  428. enterTime: "",
  429. tableData: [],
  430. sapUpload: {
  431. dialogFormVisible: false,
  432. dialogStatus: "",
  433. temp: {
  434. date: parseTime(new Date(), "{y}-{m}-{d}"),
  435. },
  436. rules: {
  437. date: [
  438. { required: true, message: "原剩料所属时间必填", trigger: "blur" },
  439. ],
  440. },
  441. getdataListParm: {
  442. name: "getSysoptEnable",
  443. page: 1,
  444. offset: 1,
  445. pagecount: 1,
  446. returntype: "Map",
  447. parammaps: {
  448. pastureid: Cookies.get("pastureid"),
  449. inforname: "sapupload",
  450. },
  451. },
  452. isSap: false,
  453. },
  454. dialogFull: false,
  455. isRoleEdit: [],
  456. getParmas: {
  457. name: "getFPList",
  458. page: 1,
  459. offset: 1,
  460. pagecount: 0,
  461. returntype: "Map",
  462. parammaps: {
  463. pastureid: Cookies.get("pastureid"),
  464. ftname: "",
  465. },
  466. },
  467. requestParams: [
  468. {
  469. name: "getBarListEnable",
  470. offset: 0,
  471. pagecount: 0,
  472. parammaps: { pastureid: Cookies.get("pastureid") },
  473. },
  474. {
  475. name: "getSysoptEnable",
  476. offset: 0,
  477. pagecount: 0,
  478. parammaps: {
  479. pastureid: Cookies.get("pastureid"),
  480. inforname: "times",
  481. },
  482. },
  483. {
  484. name: "getTMRListEnableType",
  485. offset: 0,
  486. pagecount: 0,
  487. parammaps: { pastureid: Cookies.get("pastureid"), eqtype: "1" },
  488. },
  489. ],
  490. houseNameList: [], // 栏舍名称
  491. frequencyList: [], // 收集
  492. recordList: [
  493. { id: "0", name: "手动记录" },
  494. { id: "1", name: "TMR设备自动记录" },
  495. ],
  496. record: "0",
  497. table: {
  498. getdataListParm: {
  499. name: "getWasteuse",
  500. page: 1,
  501. offset: 1,
  502. pagecount: parseInt(Cookies.get("pageCount")),
  503. returntype: "Map",
  504. parammaps: {
  505. pastureId: Cookies.get("pastureid"),
  506. ftid: "",
  507. startdate: "",
  508. enddate: "",
  509. inputDatetime: "",
  510. },
  511. },
  512. tableKey: 0,
  513. list: [],
  514. total: 0,
  515. listLoading: true,
  516. temp: {},
  517. tableKey2: 0,
  518. listLoading2: false,
  519. list2: [],
  520. },
  521. // 新增/编辑
  522. create: {
  523. dialogFormVisible: false,
  524. dialogStatus: "",
  525. temp: {
  526. pastureId: Cookies.get("pastureid"),
  527. operatetime: parseTime(new Date(), "{y}-{m}-{d} {h}:{i}"),
  528. emp: Cookies.get("employename"),
  529. ftid: "",
  530. ftname: "",
  531. weight: "",
  532. times: "1",
  533. surplusId: "",
  534. surplus: "",
  535. },
  536. rules: {
  537. ftid: [
  538. {
  539. type: "string",
  540. required: true,
  541. message: "必填",
  542. trigger: "blur",
  543. },
  544. ],
  545. weight: [
  546. {
  547. type: "string",
  548. required: true,
  549. message: "必填",
  550. trigger: "blur",
  551. },
  552. ],
  553. times: [
  554. {
  555. type: "string",
  556. required: true,
  557. message: "必填",
  558. trigger: "blur",
  559. },
  560. ],
  561. ftname: [
  562. {
  563. type: "string",
  564. required: true,
  565. message: "必填",
  566. trigger: "blur",
  567. },
  568. ],
  569. surplus: [
  570. {
  571. type: "string",
  572. required: true,
  573. message: "必填",
  574. trigger: "blur",
  575. },
  576. ],
  577. date: [
  578. {
  579. type: "string",
  580. required: true,
  581. message: "必填",
  582. trigger: "blur",
  583. },
  584. ],
  585. barid: [
  586. {
  587. type: "string",
  588. required: true,
  589. message: "必填",
  590. trigger: "blur",
  591. },
  592. ],
  593. },
  594. getdataListParm: {
  595. name: "getBarfeedremainEmpHis",
  596. page: 1,
  597. offset: 1,
  598. pagecount: 10,
  599. returntype: "Map",
  600. parammaps: {
  601. pastureid: Cookies.get("pastureid"),
  602. },
  603. },
  604. noteTakerList: [], // 记录人
  605. },
  606. textMap: {
  607. create: "新增",
  608. update: "编辑",
  609. },
  610. requestParam: {},
  611. download: {
  612. getdataListParm: {
  613. name: "getBarfeedremainList",
  614. page: 1,
  615. offset: 1,
  616. pagecount: 0,
  617. returntype: "Map",
  618. parammaps: {
  619. pastureid: Cookies.get("pastureid"),
  620. ftid: "",
  621. startdate: "",
  622. enddate: "",
  623. inputDatetime: "",
  624. },
  625. },
  626. list: [],
  627. },
  628. dataSynchronization: {
  629. dialogFormVisible: false,
  630. dialogStatus: "",
  631. getdataListParm: {
  632. name: "getSysoptEnable",
  633. page: 1,
  634. offset: 1,
  635. pagecount: 1,
  636. returntype: "Map",
  637. parammaps: {
  638. pastureid: Cookies.get("pastureid"),
  639. inforname: "wgSap",
  640. },
  641. },
  642. isDataSynchronization: false,
  643. },
  644. isokDisable: false,
  645. selectList: [],
  646. rowStyle: { maxHeight: 30 + "px", height: 30 + "px" },
  647. cellStyle: { padding: 0 + "px" },
  648. myHeight: document.documentElement.clientHeight - 85 - 150 - 45,
  649. url: "authdata/ImportExcel",
  650. };
  651. },
  652. computed: {
  653. // 设置请求头
  654. headers() {
  655. return {
  656. token: getToken(),
  657. };
  658. },
  659. uploadData() {
  660. return {
  661. name: "checkbarname,checktimes,insertBarfeedremainUpload",
  662. importParams:
  663. "栏舍名称,配方名称,原剩料所属时间,剩料量(kg),干物质,班次收集(一天/第一班/第二班/第三班),收集时间,操作人",
  664. sheetname: "Sheet1",
  665. // 登录牧场
  666. pastureid: Cookies.get("pastureid"),
  667. // 日期参数
  668. dateParams: "原剩料所属时间",
  669. // 必填参数
  670. requiredParams:
  671. "栏舍名称,剩料量(kg),班次收集(一天/第一班/第二班/第三班)",
  672. // 为数值的参数
  673. numParams: "剩料量(kg)",
  674. };
  675. },
  676. // 设置上传地址
  677. uploadExcelUrl() {
  678. // return Cookies.get('url') + 'authdata/ImportExcel'
  679. return Cookies.get("url") + "authdata/ImportExcel";
  680. },
  681. // let url = 'authdata/ImportExcel';
  682. },
  683. created() {
  684. console.log(document.querySelector("html").getAttribute("domain"), "7777");
  685. this.getDataSynchronization();
  686. this.getList();
  687. this.getDownList();
  688. this.getButtons();
  689. this.getLeftTable();
  690. },
  691. mounted() {
  692. this.$nextTick(() => {
  693. this.enterTime = Date.now();
  694. });
  695. },
  696. beforeUnmount() {
  697. const stayTime = Math.round((Date.now() - this.enterTime) / 1000);
  698. window._hmt?.push([
  699. "_trackEvent",
  700. "PageStay",
  701. "Duration",
  702. this.$route.path,
  703. stayTime,
  704. ]);
  705. },
  706. methods: {
  707. // 获取剩料列表
  708. async getLeftTable() {
  709. const { data } = await getSurplus(Cookies.get("pastureid"));
  710. console.log(data, "table");
  711. this.tableData = data;
  712. },
  713. // 获取替代方案的名字
  714. handlegetSurplus(val) {
  715. const id = this.tableData.find((item) => {
  716. return item.surplus == val;
  717. }).id;
  718. this.create.temp.surplusId = id;
  719. console.log(id, "surplus");
  720. },
  721. // 点击sap上传
  722. handleSAPUpload() {
  723. this.sapUpload.dialogStatus = "sapUpload";
  724. this.sapUpload.dialogFormVisible = true;
  725. },
  726. sapUploadData() {
  727. this.$refs["sapUpload"].validate((valid) => {
  728. if (valid) {
  729. const url = "authdata/xdmy/sap/wasteuse";
  730. const data = {
  731. pastureId: Cookies.get("pastureid"),
  732. date: parseTime(this.sapUpload.temp.date, "{y}-{m}-{d}"),
  733. };
  734. const loading = this.$loading({
  735. lock: true,
  736. text: "Loading",
  737. spinner: "el-icon-loading",
  738. background: "rgba(0, 0, 0, 0.7)",
  739. });
  740. postJson(url, data).then((response) => {
  741. setTimeout(() => {
  742. loading.close();
  743. }, 1000);
  744. if (response.msg == "ok") {
  745. this.$notify({
  746. title: "",
  747. message: "成功",
  748. type: "success",
  749. duration: 2000,
  750. });
  751. this.sapUpload.dialogFormVisible = false;
  752. this.getList();
  753. } else {
  754. this.$notify({
  755. title: "失败",
  756. message: response.data,
  757. type: "warning",
  758. duration: 2000,
  759. });
  760. }
  761. });
  762. }
  763. });
  764. },
  765. getDataSynchronization() {
  766. GetDataByName(this.dataSynchronization.getdataListParm).then(
  767. (response) => {
  768. // console.log(response.data.list[0])
  769. if (response.data.list && response.data.list[0].inforvalue == 0) {
  770. this.dataSynchronization.isDataSynchronization = false;
  771. } else {
  772. this.dataSynchronization.isDataSynchronization = true;
  773. }
  774. }
  775. );
  776. },
  777. getButtons() {
  778. const Edit = "MaterialRemainingRecord";
  779. const isRoleEdit = checkButtons(
  780. JSON.parse(sessionStorage.getItem("buttons")),
  781. Edit
  782. );
  783. this.isRoleEdit = isRoleEdit;
  784. },
  785. getDownList() {
  786. GetDataByNames(this.requestParams).then((response) => {
  787. this.houseNameList = response.data.getBarListEnable.list;
  788. this.TMRNumberList = response.data.getTMRListEnableType.list;
  789. if (response.data.getSysoptEnable.list !== null) {
  790. for (
  791. let i = 1;
  792. i <= response.data.getSysoptEnable.list[0].inforvalue;
  793. i++
  794. ) {
  795. const obj = {};
  796. obj.id = String(i);
  797. if (i == 1) {
  798. obj.name = "第一班";
  799. } else if (i == 2) {
  800. obj.name = "第二班";
  801. } else if (i == 3) {
  802. obj.name = "第三班";
  803. } else if (i == 4) {
  804. obj.name = "第四班";
  805. } else if (i == 5) {
  806. obj.name = "第五班";
  807. } else if (i == 6) {
  808. obj.name = "第六班";
  809. }
  810. this.frequencyList.push(obj);
  811. }
  812. // this.frequencyList.unshift({id:'0',name:"一天"})
  813. } else {
  814. this.frequencyList = [];
  815. }
  816. });
  817. },
  818. handleBefore() {
  819. if (
  820. this.table.getdataListParm.parammaps.inputDatetime !== "" &&
  821. this.table.getdataListParm.parammaps.inputDatetime !== null
  822. ) {
  823. var start = new Date(
  824. this.table.getdataListParm.parammaps.inputDatetime[0].setDate(
  825. this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1
  826. )
  827. );
  828. var stop = new Date(
  829. this.table.getdataListParm.parammaps.inputDatetime[1].setDate(
  830. this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1
  831. )
  832. );
  833. this.table.getdataListParm.parammaps.inputDatetime.length = 0;
  834. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop);
  835. this.$forceUpdate();
  836. }
  837. },
  838. handleNext() {
  839. if (
  840. this.table.getdataListParm.parammaps.inputDatetime !== "" &&
  841. this.table.getdataListParm.parammaps.inputDatetime !== null
  842. ) {
  843. var start = new Date(
  844. this.table.getdataListParm.parammaps.inputDatetime[0].setDate(
  845. this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1
  846. )
  847. );
  848. var stop = new Date(
  849. this.table.getdataListParm.parammaps.inputDatetime[1].setDate(
  850. this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1
  851. )
  852. );
  853. this.table.getdataListParm.parammaps.inputDatetime.length = 0;
  854. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop);
  855. this.$forceUpdate();
  856. }
  857. },
  858. getList() {
  859. this.table.listLoading = true;
  860. if (
  861. this.table.getdataListParm.parammaps.inputDatetime !== "" &&
  862. this.table.getdataListParm.parammaps.inputDatetime !== null
  863. ) {
  864. this.table.getdataListParm.parammaps.startdate = parseTime(
  865. this.table.getdataListParm.parammaps.inputDatetime[0],
  866. "{y}-{m}-{d}"
  867. );
  868. this.table.getdataListParm.parammaps.enddate = parseTime(
  869. this.table.getdataListParm.parammaps.inputDatetime[1],
  870. "{y}-{m}-{d}"
  871. );
  872. } else {
  873. this.table.getdataListParm.parammaps.inputDatetime = "";
  874. this.table.getdataListParm.parammaps.startdate = "";
  875. this.table.getdataListParm.parammaps.enddate = "";
  876. }
  877. GetDataByName(this.table.getdataListParm).then((response) => {
  878. console.log("table数据", response.data.list);
  879. if (response.data.list !== null) {
  880. this.table.list = response.data.list;
  881. this.table.pageNum = response.data.pageNum;
  882. this.table.pageSize = response.data.pageSize;
  883. this.table.total = response.data.total;
  884. } else {
  885. this.table.list = [];
  886. }
  887. setTimeout(() => {
  888. this.table.listLoading = false;
  889. }, 100);
  890. });
  891. },
  892. changeRecord(item) {
  893. if (item == "0") {
  894. this.table.getdataListParm.name = "getBarfeedremainList";
  895. } else {
  896. this.table.getdataListParm.name = "getRemainplanrecord";
  897. }
  898. this.table.getdataListParm.offset = 1;
  899. this.getList();
  900. },
  901. form_search() {
  902. console.log("点击了查询");
  903. this.table.getdataListParm.offset = 1;
  904. this.getList();
  905. },
  906. handleRefresh() {
  907. console.log("点击了重置");
  908. this.table.getdataListParm.parammaps.ftid = "";
  909. this.table.getdataListParm.parammaps.startdate = "";
  910. this.table.getdataListParm.parammaps.enddate = "";
  911. this.table.getdataListParm.parammaps.inputDatetime = "";
  912. this.table.getdataListParm.offset = 1;
  913. this.getList();
  914. },
  915. // 新增
  916. resetTemp() {
  917. this.create.temp = {
  918. pastureId: Cookies.get("pastureid"),
  919. operatetime: parseTime(new Date(), "{y}-{m}-{d} {h}:{i}"),
  920. emp: Cookies.get("employename"),
  921. ftid: "",
  922. ftname: "",
  923. weight: "",
  924. times: "1",
  925. date: "",
  926. };
  927. },
  928. blurEmp(item) {
  929. this.create.temp.emp = item.target.value;
  930. },
  931. // 栏舍名称
  932. changeBar(item) {
  933. this.create.temp.ftname = this.houseNameList.find(
  934. (obj) => obj.id === item
  935. ).bname;
  936. this.create.temp.ftid = item;
  937. this.getParmas.parammaps.barid = item;
  938. this.chooseftname();
  939. },
  940. // 根据栏舍选择配方名称
  941. chooseftname() {
  942. GetDataByName(this.getParmas).then((res) => {
  943. const { data } = res;
  944. const ftname = data.list.length && data.list[0].ftname;
  945. this.$set(this.create.temp, "ftname", ftname);
  946. // this.create.temp.ftname = ftname;
  947. console.log(this.create.temp.ftname, ftname, "配方名字");
  948. });
  949. },
  950. getNoteTakerList() {
  951. GetDataByName(this.create.getdataListParm).then((response) => {
  952. if (response.data.list !== null) {
  953. for (let i = 0; i < response.data.list.length; i++) {
  954. response.data.list[i].myId = i;
  955. }
  956. this.create.noteTakerList = response.data.list;
  957. console.log("记录人数据", response.data.list);
  958. console.log(this.create.noteTakerList);
  959. } else {
  960. this.create.noteTakerList = [];
  961. }
  962. });
  963. },
  964. handleCreate() {
  965. console.log("点击了新增", this.create);
  966. this.dialogFull = false;
  967. this.resetTemp();
  968. this.getNoteTakerList();
  969. this.create.dialogStatus = "create";
  970. this.create.dialogFormVisible = true;
  971. },
  972. createData() {
  973. console.log("点击了新增保存");
  974. console.log(this.create.temp, "发送数据");
  975. this.isokDisable = true;
  976. setTimeout(() => {
  977. this.isokDisable = false;
  978. }, 1000);
  979. this.$refs["temp"].validate((valid) => {
  980. if (valid) {
  981. this.isokDisable = true;
  982. setTimeout(() => {
  983. this.isokDisable = false;
  984. }, 1000);
  985. const weight = /^\d+(\.\d{1,2})?$/;
  986. // 剩料量
  987. if (!weight.test(parseFloat(this.create.temp.weight))) {
  988. this.$message({
  989. type: "error",
  990. message: "剩料量请输入自然数并保留两位小数",
  991. duration: 2000,
  992. });
  993. return false;
  994. }
  995. this.requestParam.name = "insertWasteuse";
  996. this.requestParam.parammaps = this.create.temp;
  997. if (this.create.temp.emp == "") {
  998. this.create.temp.emp = Cookies.get("employename");
  999. }
  1000. console.log("新增保存发送参数", this.requestParam);
  1001. PostDataByName(this.requestParam).then((response) => {
  1002. if (response.msg !== "fail") {
  1003. this.$notify({
  1004. title: "成功",
  1005. message: "保存成功",
  1006. type: "success",
  1007. duration: 2000,
  1008. });
  1009. this.create.dialogFormVisible = false;
  1010. this.getList();
  1011. } else {
  1012. const ftid = new RegExp("key 'ftid'");
  1013. if (ftid.test(response.data)) {
  1014. this.$message({
  1015. type: "error",
  1016. message: "该栏舍该班次收集今日剩料量已存在,不可重复生成",
  1017. duration: 2000,
  1018. });
  1019. } else {
  1020. this.$notify({
  1021. title: "保存失败",
  1022. message: response.data,
  1023. type: "warning",
  1024. duration: 2000,
  1025. });
  1026. }
  1027. }
  1028. });
  1029. }
  1030. });
  1031. },
  1032. // 编辑
  1033. handleUpdate(row) {
  1034. console.log("点击了编辑", row);
  1035. console.log(this.frequencyList, "frequencyList");
  1036. this.dialogFull = false;
  1037. row.ftid = String(row.ftid);
  1038. this.create.temp = Object.assign({}, row);
  1039. this.create.temp.id = row.id;
  1040. this.getNoteTakerList();
  1041. this.create.dialogStatus = "update";
  1042. this.create.dialogFormVisible = true;
  1043. },
  1044. updateData() {
  1045. this.isokDisable = true;
  1046. setTimeout(() => {
  1047. this.isokDisable = false;
  1048. }, 1000);
  1049. this.$refs["temp"].validate((valid) => {
  1050. if (valid) {
  1051. this.isokDisable = true;
  1052. setTimeout(() => {
  1053. this.isokDisable = false;
  1054. }, 1000);
  1055. const weight = /^\d+(\.\d{1,2})?$/;
  1056. // 剩料量
  1057. if (!weight.test(parseFloat(this.create.temp.weight))) {
  1058. this.$message({
  1059. type: "error",
  1060. message: "剩料量请输入自然数并保留两位小数",
  1061. duration: 2000,
  1062. });
  1063. return false;
  1064. }
  1065. this.requestParam.name = "editWasteuse";
  1066. this.requestParam.parammaps = this.create.temp;
  1067. if (this.create.temp.emp == "") {
  1068. this.create.temp.emp = Cookies.get("employename");
  1069. }
  1070. PostDataByName(this.requestParam).then((response) => {
  1071. console.log("新增保存发送参数", this.requestParam);
  1072. if (response.msg !== "fail") {
  1073. this.$notify({
  1074. title: "成功",
  1075. message: "保存成功",
  1076. type: "success",
  1077. duration: 2000,
  1078. });
  1079. this.create.dialogFormVisible = false;
  1080. this.getList();
  1081. } else {
  1082. this.$notify({
  1083. title: "保存失败",
  1084. message: response.data,
  1085. type: "warning",
  1086. duration: 2000,
  1087. });
  1088. }
  1089. });
  1090. }
  1091. });
  1092. },
  1093. // 删除
  1094. handleRowDelete(row, type) {
  1095. console.log("点击了行内删除");
  1096. MessageBox.confirm("是否确认删除此信息?", {
  1097. confirmButtonText: "确认",
  1098. cancelButtonText: "取消",
  1099. type: "warning",
  1100. })
  1101. .then(() => {
  1102. this.selectList = [];
  1103. this.requestParam.name = "delWasteuse";
  1104. this.requestParam.parammaps = {};
  1105. this.requestParam.parammaps.pastureId = row.pastureid;
  1106. if (type == 1) {
  1107. this.requestParam.parammaps.id = row;
  1108. } else {
  1109. this.requestParam.parammaps.id = row.id;
  1110. }
  1111. PostDataByName(this.requestParam).then((response) => {
  1112. if (response.msg === "fail") {
  1113. this.$notify({
  1114. title: "删除失败",
  1115. message: response.data,
  1116. type: "warning",
  1117. duration: 2000,
  1118. });
  1119. } else {
  1120. this.$notify({
  1121. title: "成功",
  1122. message: "删除成功",
  1123. type: "success",
  1124. duration: 2000,
  1125. });
  1126. this.getList();
  1127. }
  1128. });
  1129. })
  1130. .catch(() => {
  1131. this.$message({ type: "info", message: "已取消删除" });
  1132. });
  1133. },
  1134. handleSelectionChange(val) {
  1135. console.log("勾选数据", val);
  1136. this.selectList = val;
  1137. },
  1138. form_delete(type) {
  1139. console.log("点击了删除++++++++");
  1140. if (this.selectList.length == 0) {
  1141. this.$message({
  1142. type: "error",
  1143. message: "请选择栏舍剩料记录",
  1144. duration: 2000,
  1145. });
  1146. } else {
  1147. const ids = this.selectList.map((item) => {
  1148. return item.id;
  1149. });
  1150. this.handleRowDelete(ids.toString(), 1);
  1151. }
  1152. },
  1153. // 复制
  1154. handleCopy() {
  1155. console.log("点击了复制");
  1156. if (this.selectList.length == 0) {
  1157. this.$message({
  1158. type: "error",
  1159. message: "请选择栏舍剩料记录",
  1160. duration: 2000,
  1161. });
  1162. } else if (this.selectList.length == 1) {
  1163. MessageBox.confirm("是否确认复制此信息?", {
  1164. confirmButtonText: "确认",
  1165. cancelButtonText: "取消",
  1166. type: "warning",
  1167. })
  1168. .then(() => {
  1169. this.requestParam.name = "copybarfeedremain";
  1170. this.requestParam.parammaps = {};
  1171. this.requestParam.parammaps.pastureid =
  1172. this.selectList[0].pastureid;
  1173. this.requestParam.parammaps.id = this.selectList[0].id;
  1174. PostDataByName(this.requestParam).then((response) => {
  1175. if (response.msg === "fail") {
  1176. const ftid = new RegExp("key 'ftid'");
  1177. if (ftid.test(response.data)) {
  1178. this.$notify({
  1179. type: "warning",
  1180. message: "该栏舍该班次收集今日剩料量已存在,不可重复生成",
  1181. duration: 2000,
  1182. });
  1183. return;
  1184. }
  1185. this.$notify({
  1186. title: "保存失败",
  1187. message: response.data,
  1188. type: "warning",
  1189. duration: 2000,
  1190. });
  1191. } else {
  1192. this.$notify({
  1193. title: "成功",
  1194. message: "保存成功",
  1195. type: "success",
  1196. duration: 2000,
  1197. });
  1198. this.getList();
  1199. }
  1200. });
  1201. })
  1202. .catch(() => {
  1203. this.$message({ type: "info", message: "已取消复制" });
  1204. });
  1205. } else {
  1206. this.$message({
  1207. type: "error",
  1208. message: "请选择一条栏舍剩料记录",
  1209. duration: 2000,
  1210. });
  1211. }
  1212. },
  1213. // 导出
  1214. handleExport(item) {
  1215. if (item == 1) {
  1216. console.log("点击了导出模板");
  1217. console.log("点击了导出模板");
  1218. const requestParam = this.requestParam;
  1219. const url = Cookies.get("url") + "authdata/barfeedremain/excel"; // 请求下载文件的地址
  1220. console.log(url);
  1221. axios({
  1222. method: "POST",
  1223. url: url,
  1224. data: requestParam,
  1225. headers: { token: getToken(), optname: "insertcustomdoc" },
  1226. responseType: "blob",
  1227. }).then((res) => {
  1228. if (!res) return;
  1229. this.percentage = 99;
  1230. setTimeout(() => {
  1231. this.isPercentage = false;
  1232. }, 2000);
  1233. const blob = new Blob([res.data], {
  1234. type: "application/octet-stream;charset=utf-8",
  1235. });
  1236. const url = window.URL.createObjectURL(blob);
  1237. const aLink = document.createElement("a");
  1238. aLink.style.display = "none";
  1239. aLink.href = url;
  1240. const docname = "栏舍剩料记录导入模板.xlsx";
  1241. aLink.setAttribute("download", docname); // 下载的文件
  1242. document.body.appendChild(aLink);
  1243. aLink.click();
  1244. document.body.removeChild(aLink);
  1245. window.URL.revokeObjectURL(url);
  1246. });
  1247. } else {
  1248. console.log("点击了导出数据", item, this.record);
  1249. if (this.record == "0") {
  1250. this.download.getdataListParm.name = "getBarfeedremainList";
  1251. } else {
  1252. this.download.getdataListParm.name = "getRemainplanrecord";
  1253. }
  1254. this.download.getdataListParm.parammaps =
  1255. this.table.getdataListParm.parammaps;
  1256. if (
  1257. this.download.getdataListParm.parammaps.inputDatetime !== "" &&
  1258. this.download.getdataListParm.parammaps.inputDatetime !== null
  1259. ) {
  1260. this.download.getdataListParm.parammaps.startdate = parseTime(
  1261. this.download.getdataListParm.parammaps.inputDatetime[0],
  1262. "{y}-{m}-{d}"
  1263. );
  1264. this.download.getdataListParm.parammaps.enddate = parseTime(
  1265. this.download.getdataListParm.parammaps.inputDatetime[1],
  1266. "{y}-{m}-{d}"
  1267. );
  1268. } else {
  1269. this.download.getdataListParm.parammaps.inputDatetime = "";
  1270. this.download.getdataListParm.parammaps.startdate = "";
  1271. this.download.getdataListParm.parammaps.enddate = "";
  1272. }
  1273. GetDataByName(this.download.getdataListParm).then((response) => {
  1274. if (response.data.list !== null) {
  1275. this.download.list = response.data.list;
  1276. } else {
  1277. this.download.list = [];
  1278. }
  1279. if (item == 2) {
  1280. var excelDatas1 = [
  1281. {
  1282. tHeader: [
  1283. "栏舍名称",
  1284. "配方名称",
  1285. "原剩料所属时间",
  1286. "剩料量(kg)",
  1287. "班次(收集)",
  1288. "收集时间",
  1289. "操作人",
  1290. ],
  1291. filterVal: [
  1292. "ftname",
  1293. "ftname",
  1294. "date",
  1295. "weight",
  1296. "timesstr",
  1297. "operatetime",
  1298. "emp",
  1299. ],
  1300. tableDatas: this.download.list,
  1301. sheetName: "Sheet1",
  1302. },
  1303. ];
  1304. json2excel(excelDatas1, "栏舍剩料记录-手动记录", true, "xlsx");
  1305. } else {
  1306. var excelDatas2 = [
  1307. {
  1308. tHeader: [
  1309. "TMR设备编号",
  1310. "TMR设备名称",
  1311. "TMR设备类型",
  1312. "栏舍名称",
  1313. "收集时间",
  1314. "剩料重量(kg)",
  1315. "开始重量(kg)",
  1316. "结束重量(kg)",
  1317. "驾驶员",
  1318. ],
  1319. filterVal: [
  1320. "eqcode",
  1321. "eqname",
  1322. "tclassname",
  1323. "ftname",
  1324. "createtime",
  1325. "weight",
  1326. "beginweight",
  1327. "endweight",
  1328. "driver",
  1329. ],
  1330. tableDatas: this.download.list,
  1331. sheetName: "Sheet1",
  1332. },
  1333. ];
  1334. json2excel(
  1335. excelDatas2,
  1336. "栏舍剩料记录-TMR设备自动记录",
  1337. true,
  1338. "xlsx"
  1339. );
  1340. }
  1341. });
  1342. }
  1343. },
  1344. beforeImport(file) {
  1345. const isLt2M = file.size / 1024 / 1024 < 2;
  1346. if (!isLt2M) {
  1347. this.$message.error("上传文件大小不能超过 2MB!");
  1348. }
  1349. return isLt2M;
  1350. },
  1351. handleImportSuccess(res, file) {
  1352. this.getList();
  1353. if (res.msg === "ok") {
  1354. this.$message({
  1355. title: "成功",
  1356. message: "导入成功:" + res.data.success + "条!",
  1357. type: "success",
  1358. duration: 2000,
  1359. });
  1360. if (res.data.err_count > 0) {
  1361. this.$notify({
  1362. title: "失败",
  1363. message: "导入失败:" + res.data.err_count + "条!",
  1364. type: "danger",
  1365. duration: 2000,
  1366. });
  1367. import("@/vendor/Export2Excel").then((excel) => {
  1368. const list1 = res.data.result;
  1369. const tHeader = [
  1370. "栏舍名称",
  1371. "配方名称",
  1372. "原剩料所属时间",
  1373. "剩料量(kg)",
  1374. "干物质",
  1375. "班次(收集)",
  1376. "收集时间",
  1377. "操作人",
  1378. "错误信息",
  1379. ];
  1380. const filterVal = [
  1381. "栏舍名称",
  1382. "配方名称",
  1383. "原剩料所属时间",
  1384. "剩料量(kg)",
  1385. "干物质",
  1386. "班次(收集)",
  1387. "收集时间",
  1388. "操作人",
  1389. "error_msg",
  1390. ];
  1391. const data1 = this.formatJson(filterVal, list1);
  1392. excel.export_json_to_excel({
  1393. header: tHeader,
  1394. data: data1,
  1395. filename: "栏舍剩料记录导入报错信息",
  1396. autoWidth: true,
  1397. bookType: "xlsx",
  1398. });
  1399. });
  1400. }
  1401. } else {
  1402. this.$notify({
  1403. title: "失败",
  1404. message: "上传失败",
  1405. type: "danger",
  1406. duration: 2000,
  1407. });
  1408. }
  1409. },
  1410. formatJson(filterVal, jsonData) {
  1411. return jsonData.map((v) =>
  1412. filterVal.map((j) => {
  1413. if (j === "timestamp") {
  1414. return parseTime(v[j]);
  1415. } else {
  1416. return v[j];
  1417. }
  1418. })
  1419. );
  1420. },
  1421. handleDataUpload() {
  1422. let a = Cookies.get("url");
  1423. let b = a.search(8081);
  1424. let c = a.substring(0, a.search(8081)) + "8082";
  1425. let d = a.substring(0, a.lastIndexOf("/"));
  1426. console.log(d);
  1427. let url = "";
  1428. if (b == -1) {
  1429. url = d + ":8082";
  1430. } else {
  1431. url = c;
  1432. }
  1433. console.log(url, "url");
  1434. let _url = url + "/authdata/surplus/push";
  1435. let data = {
  1436. date: parseTime(new Date(), "{y}-{m}-{d}"),
  1437. pastureId: Cookies.get("pastureid"),
  1438. };
  1439. console.log(_url, "_url");
  1440. postJson2(_url, data).then((response) => {
  1441. if (response.msg == "ok") {
  1442. this.$notify({
  1443. title: "",
  1444. message: response.data,
  1445. type: "success",
  1446. duration: 2000,
  1447. });
  1448. } else {
  1449. this.$notify({
  1450. title: "上传失败",
  1451. message: response.data,
  1452. type: "warning",
  1453. duration: 2000,
  1454. });
  1455. }
  1456. });
  1457. },
  1458. },
  1459. };
  1460. </script>