SalePig.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-12-07 10:07:56
  4. * @LastEditTime: 2022-01-04 13:19:38
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 电子秤 - TODO: 卖猪计量的视频回放按钮
  7. * @FilePath: \hyyfClient\src\views\Env\SalePig.vue
  8. -->
  9. <template>
  10. <div class="sale-pig">
  11. <div class="reply" :style="{ color: color }">
  12. <div class="reset-title">
  13. <span>卖猪重量计量</span>
  14. <div class="reset-btns">
  15. <span>视频监控:</span>
  16. <el-button size="small" @click="handlePlay(1)">卖猪台点猪</el-button>
  17. <el-button size="small" @click="handlePlay(2)">卖猪台猪舍</el-button>
  18. </div>
  19. </div>
  20. </div>
  21. <x-form
  22. :formItems="formItems"
  23. :day="day"
  24. @setDay="setDay"
  25. @onClickType="onClickType"
  26. >
  27. </x-form>
  28. <div class="echarts">
  29. <div class="echarts-l">
  30. <chart-sale-pig :starkCount="elecAllCount"></chart-sale-pig>
  31. </div>
  32. <div class="echarts-r">
  33. <!-- <chart-stark-bar :starkList="starkAllList"></chart-stark-bar> -->
  34. <chart-elec-lines :data="elecData"></chart-elec-lines>
  35. </div>
  36. </div>
  37. <br />
  38. <div class="reply" :style="{ color: color }">重量详情</div>
  39. <x-form
  40. :formItems="formItemsTable"
  41. :day="dayTable"
  42. @setDay="setDayTable"
  43. @onClickType="onClickTypeTable"
  44. >
  45. </x-form>
  46. <table-content
  47. :listData="elecDataList"
  48. :tableItems="tableItems"
  49. :shows="shows"
  50. >
  51. </table-content>
  52. <table-footer
  53. :totals="total"
  54. :size="pageSize"
  55. @sizeChange="sizeChange"
  56. @pageChange="pageChange"
  57. >
  58. </table-footer>
  59. <el-dialog title="实时视频" :visible.sync="videoVisible" width="50%">
  60. <div style="width: 100%; height: 560px">
  61. <iframe
  62. v-if="videoVisible"
  63. :src="rtsp"
  64. frameborder="0"
  65. style="width: 100%; height: 530px;"
  66. >
  67. </iframe>
  68. </div>
  69. <span slot="footer" class="dialog-footer">
  70. <el-button @click="videoVisible = false">关 闭</el-button>
  71. </span>
  72. </el-dialog>
  73. </div>
  74. </template>
  75. <script>
  76. import { mapState } from "vuex";
  77. import XForm from "@/components/XForm";
  78. import ChartSalePig from "./chart/ChartSalePig.vue";
  79. import ChartElecLines from "./chart/ChartElecLines.vue";
  80. import TableContent from "@/components/newTable/TableContent";
  81. import TableFooter from "@/components/TableFooter";
  82. import {
  83. getDayWeight,
  84. getDaysQuery,
  85. getMonthQuery,
  86. getQuery,
  87. } from "@/utils/chenApi.js";
  88. export default {
  89. components: {
  90. XForm,
  91. ChartSalePig,
  92. ChartElecLines,
  93. TableContent,
  94. TableFooter,
  95. },
  96. computed: {
  97. ...mapState(["color"]),
  98. },
  99. data() {
  100. return {
  101. formItems: [
  102. {
  103. id: 2,
  104. type: "text",
  105. text: "近七次",
  106. value: 1,
  107. col: 1.5,
  108. },
  109. {
  110. id: 3,
  111. type: "text",
  112. text: "本月",
  113. value: 2,
  114. col: 1,
  115. },
  116. {
  117. id: 4,
  118. type: "datepicker",
  119. placeholder: [],
  120. field: "value1",
  121. col: 6,
  122. },
  123. {
  124. id: 8,
  125. type: "button",
  126. text: "查询",
  127. col: 2,
  128. click: "search",
  129. },
  130. ],
  131. day: 1,
  132. params: {},
  133. // 卖猪详情的查询
  134. formItemsTable: [
  135. {
  136. id: 2,
  137. type: "text",
  138. text: "今日",
  139. value: 1,
  140. col: 1.5,
  141. },
  142. {
  143. id: 4,
  144. type: "datepicker",
  145. placeholder: [],
  146. field: "value1",
  147. col: 6,
  148. },
  149. {
  150. id: 8,
  151. type: "button",
  152. text: "查询",
  153. col: 2,
  154. click: "search",
  155. },
  156. ],
  157. dayTable: 1,
  158. paramsTable: {},
  159. elecAllCount: "0",
  160. elecData: {
  161. month: [],
  162. elecList: [],
  163. },
  164. elecDataList: [],
  165. tableItems: [
  166. {
  167. prop: "addTime",
  168. label: "时间",
  169. minWidth: "100",
  170. slotName: "addTime",
  171. },
  172. {
  173. prop: "grossWeight",
  174. label: "毛重",
  175. minWidth: "100",
  176. slotName: "grossWeight",
  177. },
  178. {
  179. prop: "tareWeight",
  180. label: "去皮",
  181. minWidth: "100",
  182. slotName: "tareWeight",
  183. },
  184. {
  185. prop: "netWeight",
  186. label: "净重",
  187. minWidth: "100",
  188. slotName: "netWeight",
  189. },
  190. ],
  191. shows: {
  192. showIndex: false,
  193. showSelect: false,
  194. },
  195. total: 0,
  196. pageNum: 1,
  197. pageSize: 20,
  198. videoVisible: false, // 视频回放
  199. rtsp: "", // 视频回放的地址
  200. };
  201. },
  202. mounted() {
  203. this.initDayWeight();
  204. this.initDaysQuery();
  205. },
  206. methods: {
  207. setDay(data) {
  208. this.day = data.type;
  209. if (this.day === 1) {
  210. this.initDaysQuery();
  211. } else if (this.day === 2) {
  212. this.initMonthQuery();
  213. }
  214. },
  215. onClickType(data) {
  216. this.day = 3; // 让 近七次 和 本月 不选中
  217. this.params.time = data.data.value1;
  218. if (!this.params.time) {
  219. this.$message.info("请选择时间");
  220. return;
  221. }
  222. this.initQuery();
  223. },
  224. // 修改size
  225. sizeChange(val) {
  226. this.pageSize = val;
  227. this.pageNum = 1;
  228. this.initDayWeight();
  229. },
  230. // 修改页数
  231. pageChange(val) {
  232. this.pageNum = val;
  233. this.initDayWeight();
  234. },
  235. // 重量详情
  236. initDayWeight() {
  237. this.pageNum = 1;
  238. getDayWeight({
  239. pageNo: this.pageNum,
  240. pageSize: this.pageSize,
  241. startDate: this.paramsTable.time ? this.paramsTable.time[0] : undefined,
  242. endDate: this.paramsTable.time ? this.paramsTable.time[1] : undefined,
  243. days: this.paramsTable.time ? undefined : 0,
  244. }).then((res) => {
  245. if (res.code === 10000) {
  246. this.elecDataList = res.data.content;
  247. this.elecDataList.forEach((item) => {
  248. item.grossWeight += " kg";
  249. item.tareWeight += " kg";
  250. item.netWeight += " kg";
  251. });
  252. this.total = res.data.totalElements;
  253. } else {
  254. this.elecDataList = [];
  255. this.total = 0;
  256. }
  257. });
  258. },
  259. // 近七次
  260. initDaysQuery() {
  261. getDaysQuery({
  262. days: 7,
  263. }).then((res) => {
  264. if (res.code === 10000) {
  265. this.elecAllCount = res.data.total;
  266. const list = res.data.weight;
  267. this.elecData = {
  268. month: [],
  269. elecList: [],
  270. };
  271. list.forEach((item) => {
  272. this.elecData.month.push(item.addTime.split("T")[0]);
  273. this.elecData.elecList.push(item.netWeight);
  274. });
  275. } else {
  276. this.elecAllCount = "0";
  277. this.elecData = {
  278. month: [],
  279. elecList: [],
  280. };
  281. }
  282. });
  283. },
  284. // 本月
  285. initMonthQuery() {
  286. getMonthQuery({}).then((res) => {
  287. if (res.code === 10000) {
  288. this.elecAllCount = res.data.total;
  289. const list = res.data.weight;
  290. this.elecData = {
  291. month: [],
  292. elecList: [],
  293. };
  294. list.forEach((item) => {
  295. this.elecData.month.push(item.addTime.split("T")[0]);
  296. this.elecData.elecList.push(item.netWeight);
  297. });
  298. } else {
  299. this.elecAllCount = "0";
  300. this.elecData = {
  301. month: [],
  302. elecList: [],
  303. };
  304. }
  305. });
  306. },
  307. // 指定日期
  308. initQuery() {
  309. getQuery({
  310. startDate: this.params.time[0],
  311. endDate: this.params.time[1],
  312. }).then((res) => {
  313. if (res.code === 10000) {
  314. this.elecAllCount = res.data.total;
  315. const list = res.data.weight;
  316. this.elecData = {
  317. month: [],
  318. elecList: [],
  319. };
  320. list.forEach((item) => {
  321. this.elecData.month.push(item.addTime.split("T")[0]);
  322. this.elecData.elecList.push(item.netWeight);
  323. });
  324. } else {
  325. this.elecAllCount = "0";
  326. this.elecData = {
  327. month: [],
  328. elecList: [],
  329. };
  330. }
  331. });
  332. },
  333. // 卖猪详情 - 今日
  334. setDayTable() {
  335. this.paramsTable = {};
  336. this.initDayWeight();
  337. },
  338. onClickTypeTable(data) {
  339. this.dayTable = 8; // 随便什么数字,反正今日不被选中
  340. this.paramsTable.time = data.data.value1;
  341. if (!this.paramsTable.time) {
  342. this.$message.info("请选择时间");
  343. return;
  344. }
  345. this.initDayWeight();
  346. },
  347. // 卖猪视频播放
  348. handlePlay(val) {
  349. if (val === 1) {
  350. this.rtsp =
  351. "static/jinm/index.html?" +
  352. "1" +
  353. "," +
  354. "ws://36.26.62.70:9080/camera_relay?tcpaddr=admin%3Ahmkj6688%40172.16.3.193" +
  355. "," +
  356. "rtsp://admin:hmkj6688@172.16.3.193/cam/realmonitor?channel=1&subtype=0" +
  357. "," +
  358. "100%" +
  359. "," +
  360. "0";
  361. } else {
  362. this.rtsp =
  363. "static/jinm/index.html?" +
  364. "1" +
  365. "," +
  366. "ws://36.26.62.70:9080/camera_relay?tcpaddr=admin%3Ahmkj6688%40172.16.3.192" +
  367. "," +
  368. "rtsp://admin:hmkj6688@172.16.3.193/cam/realmonitor?channel=1&subtype=0" +
  369. "," +
  370. "100%" +
  371. "," +
  372. "0";
  373. }
  374. this.videoVisible = true;
  375. },
  376. },
  377. };
  378. </script>
  379. <style scoped>
  380. .sale-pig {
  381. width: 100%;
  382. height: 100%;
  383. box-sizing: border-box;
  384. padding: 20px 20px 0 20px;
  385. }
  386. .reply {
  387. width: 100%;
  388. border: 1px solid #ddd;
  389. border-bottom: 0;
  390. height: 50px;
  391. background-color: #f3f3f3;
  392. line-height: 50px;
  393. font-size: 18px;
  394. box-sizing: border-box;
  395. padding-left: 20px;
  396. }
  397. /* 为了放视频按钮 */
  398. .reset-title {
  399. display: flex;
  400. justify-content: space-between;
  401. align-items: center;
  402. padding-right: 20px;
  403. }
  404. .reset-btns {
  405. display: flex;
  406. align-items: center;
  407. }
  408. .reset-btns > span {
  409. color: #000;
  410. margin-right: 3px;
  411. }
  412. .echarts {
  413. width: 100%;
  414. height: 401px;
  415. box-sizing: border-box;
  416. border: 1px solid #ddd;
  417. border-top: 0;
  418. display: flex;
  419. }
  420. .echarts-l {
  421. width: 30%;
  422. height: 100%;
  423. }
  424. .echarts-r {
  425. width: 70%;
  426. height: 100%;
  427. }
  428. </style>