index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-time-picker
  5. v-model="table.parammaps.date"
  6. style="width: 250px"
  7. value-format="HH:mm:ss"
  8. />
  9. <el-input
  10. v-model="table.parammaps.eqCode"
  11. :placeholder="$t('premixedPlan.clbm')"
  12. style="width: 180px"
  13. class="filter-item"
  14. clearable
  15. />
  16. <!-- <el-select v-model="table.getdataListParm.parammaps.enable" filterable :placeholder="$t('formulationEvaluation.sfqy')" class="filter-item" style="width: 120px;" clearable>
  17. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  18. </el-select> -->
  19. <el-button class="successBorder" @click="handleRefresh">{{
  20. $t("common.reset")
  21. }}</el-button>
  22. <el-button class="successBorder" @click="form_search">{{
  23. $t("common.query")
  24. }}</el-button>
  25. </div>
  26. <div class="operation">
  27. <el-button
  28. v-if="isRoleEdit"
  29. class="success"
  30. icon="el-icon-plus"
  31. style="float: left"
  32. @click="handleCreate"
  33. >{{ $t("formulationEvaluation.add") }}</el-button
  34. >
  35. </div>
  36. <div class="table">
  37. <el-table
  38. :key="table.tableKey"
  39. ref="table"
  40. v-loading="table.listLoading"
  41. :element-loading-text="$t('common.tableMsg')"
  42. :data="table.list"
  43. border
  44. fit
  45. highlight-current-row
  46. style="width: 100%"
  47. :row-style="rowStyle"
  48. :cell-style="cellStyle"
  49. class="elTable table-fixed"
  50. @selection-change="handleSelect"
  51. :max-height="myHeight"
  52. >
  53. <el-table-column type="selection" width="50" />
  54. <el-table-column
  55. :key="1"
  56. :label="$t('formulationEvaluation.xh')"
  57. align="center"
  58. type="index"
  59. width="50px"
  60. class-name="small-padding fixed-width"
  61. fixed="left"
  62. />
  63. <el-table-column
  64. :label="$t('premixedPlan.tlc')"
  65. min-width="100px"
  66. align="center"
  67. class-name="small-padding fixed-width"
  68. fixed="left"
  69. prop="tname"
  70. />
  71. <el-table-column
  72. :label="$t('premixedPlan.time')"
  73. min-width="100px"
  74. align="center"
  75. prop="date"
  76. />
  77. <el-table-column
  78. :label="$t('formulationEvaluation.remark')"
  79. min-width="100px"
  80. align="center"
  81. prop="remark"
  82. />
  83. <el-table-column
  84. :label="$t('errorAnalysis.pen')"
  85. min-width="100px"
  86. align="center"
  87. prop="bname"
  88. />
  89. <el-table-column
  90. :label="$t('premixedPlan.status')"
  91. min-width="90px"
  92. align="center"
  93. >
  94. <template slot-scope="scope">
  95. <el-switch
  96. v-model="scope.row.enable"
  97. :disabled="scope.row.NoEdit == true"
  98. active-color="#13ce66"
  99. inactive-color="#ff4949"
  100. :active-value="1"
  101. :inactive-value="0"
  102. @change="handleEnableChange(scope.$index, scope.row)"
  103. />
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. :label="$t('errorAnalysis.cz')"
  108. align="center"
  109. width="80"
  110. class-name="small-padding fixed-width"
  111. fixed="right"
  112. >
  113. <template slot-scope="{ row }">
  114. <el-button
  115. v-if="isRoleEdit"
  116. class="miniSuccess"
  117. icon="el-icon-edit-outline"
  118. @click="handleUpdate(row)"
  119. />
  120. <el-button
  121. v-if="isRoleEdit"
  122. class="miniDanger"
  123. icon="el-icon-delete"
  124. @click="handleRowDelete(row)"
  125. />
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. <span
  130. v-if="table.listLoading == false"
  131. style="margin-right: 30px; margin-top: 10px; font-size: 14px"
  132. >{{ $t("processAnalysis.total") }}{{ table.total
  133. }}{{ $t("processAnalysis.tiao") }}</span
  134. >
  135. </div>
  136. <el-dialog
  137. :fullscreen="dialogFull"
  138. :visible.sync="create.dialogFormVisible"
  139. :close-on-click-modal="false"
  140. width="50%"
  141. >
  142. <template slot="title">
  143. <div class="avue-crud__dialog__header">
  144. <span class="el-dialog__title">
  145. <span
  146. style="
  147. display: inline-block;
  148. width: 3px;
  149. height: 20px;
  150. margin-right: 5px;
  151. float: left;
  152. margin-top: 2px;
  153. "
  154. />
  155. {{ $t("premixedPlan.tljh") }}
  156. </span>
  157. <div
  158. class="avue-crud__dialog__menu"
  159. @click="dialogFull ? (dialogFull = false) : (dialogFull = true)"
  160. >
  161. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  162. <svg-icon v-else icon-class="fullscreen" />
  163. </div>
  164. </div>
  165. </template>
  166. <div class="app-add">
  167. <el-form
  168. ref="temp"
  169. :rules="create.rules"
  170. :model="create.temp"
  171. label-position="right"
  172. label-width="155px"
  173. style="width: 100%; margin: 0 auto 50px"
  174. >
  175. <el-row>
  176. <el-col :span="12">
  177. <el-form-item :label="$t('premixedPlan.tlc')" prop="tmrId">
  178. <el-select
  179. v-model="create.temp.tmrId"
  180. filterable
  181. :placeholder="$t('premixedPlan.tlc')"
  182. class="filter-item"
  183. style="width: 100%"
  184. >
  185. <el-option
  186. v-for="item in tmrList"
  187. :key="item.id"
  188. :label="item.tname"
  189. :value="item.id"
  190. />
  191. </el-select>
  192. </el-form-item>
  193. </el-col>
  194. </el-row>
  195. <el-row>
  196. <el-col :span="12">
  197. <el-form-item :label="$t('premixedPlan.time')" prop="date">
  198. <el-time-picker
  199. v-model="create.temp.date"
  200. style="width: 100%"
  201. value-format="HH:mm:ss"
  202. />
  203. </el-form-item>
  204. </el-col>
  205. </el-row>
  206. <el-row>
  207. <el-col :span="12">
  208. <el-form-item
  209. :label="$t('formulationEvaluation.remark')"
  210. prop="remark"
  211. >
  212. <el-input
  213. ref="remark"
  214. v-model="create.temp.remark"
  215. class="filter-item"
  216. :placeholder="$t('formulationEvaluation.remark')"
  217. type="text"
  218. style="width: 100%"
  219. />
  220. </el-form-item>
  221. </el-col>
  222. </el-row>
  223. <el-row>
  224. <el-col :span="12">
  225. <el-form-item :label="$t('premixedPlan.ls')" prop="barId">
  226. <el-select
  227. v-model="create.temp.barId"
  228. multiple
  229. filterable
  230. :placeholder="$t('errorAnalysis.pen')"
  231. class="filter-item"
  232. style="width: 100%"
  233. >
  234. <el-option
  235. v-for="item in barList"
  236. :key="item.id"
  237. :label="item.bname"
  238. :value="item.id"
  239. />
  240. </el-select>
  241. </el-form-item>
  242. </el-col>
  243. </el-row>
  244. <el-row>
  245. <el-col :span="12">
  246. <el-form-item :label="$t('premixedPlan.status')" prop="enable">
  247. <el-switch
  248. v-model="create.temp.enable"
  249. active-color="#13ce66"
  250. inactive-color="#ff4949"
  251. :active-value="1"
  252. :inactive-value="0"
  253. />
  254. </el-form-item>
  255. </el-col>
  256. </el-row>
  257. </el-form>
  258. <div slot="footer" class="dialog-footer">
  259. <el-button
  260. class="cancelClose"
  261. @click="
  262. create.dialogFormVisible = false;
  263. getList();
  264. "
  265. >{{ $t("common.closed") }}</el-button
  266. >
  267. <el-button
  268. class="save"
  269. @click="
  270. create.dialogStatus = 'create' ? createData() : updateData()
  271. "
  272. :disabled="isokDisable"
  273. >{{ $t("errorAnalysis.confirm") }}</el-button
  274. >
  275. </div>
  276. </div>
  277. </el-dialog>
  278. </div>
  279. </template>
  280. <script>
  281. import {
  282. GetDataByName,
  283. postJson,
  284. getJson,
  285. formatNum,
  286. checkButtons,
  287. } from "@/api/common";
  288. import { parseTime } from "@/utils/index.js";
  289. import { MessageBox } from "element-ui";
  290. import Cookies from "js-cookie";
  291. import axios from "axios";
  292. import { getToken } from "@/utils/auth";
  293. export default {
  294. name: "PushMaterialPlan",
  295. data() {
  296. return {
  297. table: {
  298. parammaps: {
  299. pastureid: Cookies.get("pastureid"),
  300. date: "",
  301. eqCode: "",
  302. },
  303. tableKey: 0,
  304. list: [],
  305. total: 0,
  306. listLoading: true,
  307. },
  308. create: {
  309. dialogFormVisible: false,
  310. dialogStatus: "",
  311. temp: {
  312. pastureId: Cookies.get("pastureid"),
  313. tmrId: "",
  314. date: "",
  315. remark: "",
  316. barId: "",
  317. enable: "",
  318. },
  319. rules: {
  320. tmrId: [
  321. {
  322. required: true,
  323. message: this.$t("hardwareTest.bt"),
  324. trigger: "blur",
  325. },
  326. ],
  327. date: [
  328. {
  329. required: true,
  330. message: this.$t("hardwareTest.bt"),
  331. trigger: "blur",
  332. },
  333. ],
  334. remark: [
  335. {
  336. required: true,
  337. message: this.$t("hardwareTest.bt"),
  338. trigger: "blur",
  339. },
  340. ],
  341. barId: [
  342. {
  343. required: true,
  344. message: this.$t("hardwareTest.bt"),
  345. trigger: "blur",
  346. },
  347. ],
  348. enable: [
  349. {
  350. required: true,
  351. message: this.$t("hardwareTest.bt"),
  352. trigger: "blur",
  353. },
  354. ],
  355. },
  356. },
  357. dialogFull: false,
  358. tmrList: [],
  359. barList: [],
  360. isRoleEdit: [],
  361. selectList: [],
  362. isokDisable: false,
  363. rowStyle: { maxHeight: 30 + "px", height: 30 + "px" },
  364. cellStyle: { padding: 0 + "px" },
  365. myHeight: document.documentElement.clientHeight - 85 - 150,
  366. };
  367. },
  368. created() {
  369. this.getButtons();
  370. this.getTMR_barList();
  371. this.getList();
  372. },
  373. methods: {
  374. getButtons() {
  375. const Edit = "PushMaterialPlan";
  376. const isRoleEdit = checkButtons(
  377. JSON.parse(sessionStorage.getItem("buttons")),
  378. Edit
  379. );
  380. this.isRoleEdit = isRoleEdit;
  381. },
  382. getTMR_barList() {
  383. let url = "/authdata/GetDataByName";
  384. let data = {
  385. name: "getTMRList",
  386. page: 1,
  387. offset: 1,
  388. parammaps: {
  389. pastureid: Cookies.get("pastureid"),
  390. eqtype: "1",
  391. },
  392. };
  393. postJson(url, data).then((response) => {
  394. if (response.data.list !== null) {
  395. this.tmrList = response.data.list;
  396. } else {
  397. this.tmrList = [];
  398. }
  399. });
  400. let url2 = "/authdata/GetDataByName";
  401. let data2 = {
  402. name: "getBarList",
  403. page: 1,
  404. offset: 1,
  405. parammaps: {
  406. pastureid: Cookies.get("pastureid"),
  407. },
  408. };
  409. postJson(url2, data2).then((response) => {
  410. if (response.data.list !== null) {
  411. this.barList = response.data.list;
  412. } else {
  413. this.barList = [];
  414. }
  415. });
  416. },
  417. getList() {
  418. this.table.listLoading = true;
  419. let url = "/authdata/tmrequipment";
  420. let data =
  421. "?pastureId=" +
  422. Cookies.get("pastureid") +
  423. "&offset=1" +
  424. "&page=50" +
  425. "&date=" +
  426. this.table.parammaps.date +
  427. "&eqCode=" +
  428. this.table.parammaps.eqCode;
  429. getJson(url, data).then((response) => {
  430. console.log("table数据", response.data.list);
  431. if (response.data.list !== null) {
  432. this.table.list = response.data.data;
  433. } else {
  434. this.table.list = [];
  435. }
  436. this.table.total = response.data.count;
  437. setTimeout(() => {
  438. this.table.listLoading = false;
  439. }, 100);
  440. });
  441. },
  442. // 新增
  443. handleCreate() {
  444. this.resetTemp();
  445. this.dialogFull = false;
  446. this.create.dialogStatus = "create";
  447. this.create.dialogFormVisible = true;
  448. },
  449. resetTemp() {
  450. this.create.temp.tmrId = "";
  451. this.create.temp.pastureId = Cookies.get("pastureid");
  452. this.create.temp.date = "";
  453. this.create.temp.remark = "";
  454. this.create.temp.barId = "";
  455. this.create.temp.enable = 1;
  456. },
  457. createData() {
  458. this.isokDisable = true;
  459. setTimeout(() => {
  460. this.isokDisable = false;
  461. }, 1000);
  462. this.$refs["temp"].validate((valid) => {
  463. if (valid) {
  464. let url = "/authdata/tmrequipment/edit";
  465. let data = this.create.temp;
  466. data.barId = this.create.temp.barId.join();
  467. // data.date = parseTime(this.create.temp.date,'{h}:{i}:{s}')
  468. postJson(url, data).then((response) => {
  469. if (response.msg == "fail") {
  470. this.$notify({
  471. title: this.$t("driver.saveFail"),
  472. message: response.data,
  473. type: "warning",
  474. duration: 2000,
  475. });
  476. } else {
  477. this.$notify({
  478. title: this.$t("common.succes"),
  479. message: this.$t("driver.saveSuccess"),
  480. type: "success",
  481. duration: 2000,
  482. });
  483. this.create.dialogFormVisible = false;
  484. this.getList();
  485. }
  486. });
  487. }
  488. });
  489. },
  490. // 编辑
  491. handleUpdate(row) {
  492. this.create.temp = Object.assign({}, row);
  493. this.create.temp.barId = row.barId.split(",");
  494. this.dialogFull = false;
  495. this.create.dialogStatus = "create";
  496. this.create.dialogFormVisible = true;
  497. },
  498. updateData(row) {
  499. this.isokDisable = true;
  500. setTimeout(() => {
  501. this.isokDisable = false;
  502. }, 1000);
  503. this.$refs["temp"].validate((valid) => {
  504. if (valid) {
  505. let url = "/authdata/tmrequipment/edit";
  506. let data = this.create.temp;
  507. data.barId = this.create.temp.barId.join();
  508. // data.date = parseTime(this.create.temp.date,'{h}:{i}:{s}')
  509. postJson(url, data).then((response) => {
  510. if (response.msg == "fail") {
  511. this.$notify({
  512. title: this.$t("driver.saveFail"),
  513. message: response.data,
  514. type: "warning",
  515. duration: 2000,
  516. });
  517. } else {
  518. this.$notify({
  519. title: this.$t("common.succes"),
  520. message: this.$t("driver.saveSuccess"),
  521. type: "success",
  522. duration: 2000,
  523. });
  524. this.create.dialogFormVisible = false;
  525. this.getList();
  526. }
  527. });
  528. }
  529. });
  530. },
  531. handleRowDelete(row) {
  532. let url = "/authdata/tmrequipment/del";
  533. let data = {};
  534. data.id = row.id;
  535. postJson(url, data).then((response) => {
  536. if (response.msg == "fail") {
  537. this.$notify({
  538. title: this.$t("common.delfail"),
  539. message: response.data,
  540. type: "warning",
  541. duration: 2000,
  542. });
  543. } else {
  544. this.$notify({
  545. title: this.$t("common.succes"),
  546. message: this.$t("common.delSuccess"),
  547. type: "success",
  548. duration: 2000,
  549. });
  550. this.getList();
  551. }
  552. });
  553. },
  554. handleSelect(val) {
  555. console.log("勾选数据", val);
  556. this.selectList = val;
  557. },
  558. handleEnableChange(index, row) {
  559. console.log("点击了是否启用");
  560. let url = "/authdata/tmrequipment/edit";
  561. let data = row;
  562. // data.barId = row.barId.join()
  563. // data.date = parseTime(this.create.temp.date,'{h}:{i}:{s}')
  564. postJson(url, data).then((response) => {
  565. if (response.msg == "fail") {
  566. this.$notify({
  567. title: this.$t("driver.saveFail"),
  568. message: response.data,
  569. type: "warning",
  570. duration: 2000,
  571. });
  572. } else {
  573. this.$notify({
  574. title: this.$t("common.succes"),
  575. message: this.$t("driver.saveSuccess"),
  576. type: "success",
  577. duration: 2000,
  578. });
  579. this.create.dialogFormVisible = false;
  580. this.getList();
  581. }
  582. });
  583. },
  584. form_search() {
  585. console.log("点击了查询");
  586. this.getList();
  587. },
  588. handleRefresh() {
  589. this.table.parammaps.date = "";
  590. this.table.parammaps.eqCode = "";
  591. },
  592. },
  593. };
  594. </script>
  595. <style lang="scss" scoped>
  596. .search {
  597. clear: both;
  598. }
  599. .table {
  600. margin-top: 10px;
  601. }
  602. .el-tag {
  603. margin-right: 5px;
  604. }
  605. </style>
  606. <style lang="scss">
  607. .red-row {
  608. background: #fde2e2 !important;
  609. }
  610. </style>