Index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索模块 -->
  4. <div class="filter-container">
  5. <!--<span>
  6. <span>{{$t("lineSide.searchForm.name")}}:</span>
  7. <el-input v-model="queryParams.model.name" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
  8. </span>-->
  9. <span>
  10. <span>{{$t("resource.searchForm.startEndTime")}}:</span>
  11. <el-date-picker
  12. v-model="queryParams.timeRange"
  13. type="daterange"
  14. :picker-options="pickerOptions"
  15. :range-separator='$t("common.separator")'
  16. :start-placeholder='$t("common.startTime")'
  17. :end-placeholder='$t("common.endTime")'
  18. format="yyyy-MM-dd"
  19. value-format="yyyy-MM-dd"
  20. align="right">
  21. </el-date-picker>
  22. </span>
  23. <!--<span style="margin-left: 15px;">
  24. <span>{{$t("lineSide.common.type")}}:</span>
  25. <el-select v-model="queryParams.model.optType" :placeholder='$t("common.pleaseSelect")' size="medium" style="width: 150px;">
  26. <el-option
  27. v-for="item in audioStatus"
  28. :key="item.value"
  29. :label="item.label"
  30. :value="item.value">
  31. </el-option>
  32. </el-select>
  33. </span>-->
  34. <span style="margin-left: 15px;">
  35. <el-button plain type="primary" icon="el-icon-search" size="medium" @click="search">
  36. {{ $t("table.search") }}
  37. </el-button>
  38. <el-button plain type="warning" icon="el-icon-refresh" size="medium" @click="reset">
  39. {{ $t("table.reset") }}
  40. </el-button>
  41. </span>
  42. </div>
  43. <!-- 功能按钮 -->
  44. <el-row class="filter-container">
  45. <el-col>
  46. <el-button v-has-permission="['warnLong:delete']" type="danger" icon="el-icon-delete" size="medium" @click="batchDelete">
  47. {{ $t("table.delete") }}
  48. </el-button>
  49. <el-button v-has-permission="['warnLong:tags']" type="primary" icon="el-icon-plus" size="medium" @click="marking">{{ $t("developer.buttons.marking") }}</el-button>
  50. <!--<el-button type="success" icon="el-icon-edit" size="medium" @click="editOne">
  51. {{ $t("common.edit") }}
  52. </el-button>-->
  53. </el-col>
  54. </el-row>
  55. <!-- 列表数据 -->
  56. <el-table
  57. :key="tableKey"
  58. ref="table"
  59. v-loading="loading"
  60. :data="tableData.records"
  61. border
  62. fit
  63. row-key="id"
  64. style="width: 100%;"
  65. @selection-change="onSelectChange"
  66. @cell-click="cellClick"
  67. >
  68. <!-- 序号 -->
  69. <el-table-column :label='$t("common.serialNo")' width="55px" align="center">
  70. <template slot-scope="scope">
  71. <div>
  72. {{scope.$index+(queryParams.current - 1) * queryParams.size + 1}}
  73. </div>
  74. </template>
  75. </el-table-column>
  76. <!-- CheckBox -->
  77. <el-table-column align="center" type="selection" width="50" :reserve-selection="true" />
  78. <!-- 编码 -->
  79. <el-table-column prop="nodeNo" :label='$t("developer.table.warnLong.no")' :show-overflow-tooltip="true" width="180"></el-table-column>
  80. <!-- 设备 -->
  81. <el-table-column prop="resourceName" :label='$t("developer.table.warnLong.name")' width="100"></el-table-column>
  82. <!-- 报警内容 -->
  83. <el-table-column prop="shelvesDesc" :label='$t("developer.table.warnLong.storgeId")' width="180px">
  84. <template slot-scope="{ row }">
  85. <span> {{row.resourceName}}-{{row.procedureName}}-{{row.instructionName}}-</span>
  86. <span v-if="row.feedback">{{row.feedback}}</span>
  87. <span else="">任务超时</span>
  88. </template>
  89. </el-table-column>
  90. <!-- 报警时间 -->
  91. <el-table-column prop="createTime" :label='$t("developer.table.warnLong.updateTime")' width="180px"></el-table-column>
  92. <!-- 是否需要人员处理 -->
  93. <el-table-column prop="num" :label='$t("developer.table.warnLong.num")' align="center" width="150px">
  94. <template slot-scope="{ row }">
  95. <el-tag v-if="row.feedback" type="success">{{$t("common.yes")}}</el-tag>
  96. <el-tag v-else type="">{{$t("common.no")}}</el-tag>
  97. </template>
  98. </el-table-column>
  99. <!-- 处理状态 -->
  100. <el-table-column prop="optType" :label='$t("developer.table.warnLong.goodsType")' align="center" width="120px">
  101. <template slot-scope="{ row }">
  102. <el-tag v-if="row.status == '0'" type="failed">{{$t("developer.common.status.start")}}</el-tag>
  103. <el-tag v-if="row.status == '1'" type="success">{{$t("developer.common.status.end")}}</el-tag>
  104. </template>
  105. </el-table-column>
  106. <!-- 处理时间 -->
  107. <el-table-column prop="updateTime" :label='$t("developer.table.warnLong.chuliTime")' width="180px">
  108. <template slot-scope="{ row }">
  109. <span v-if="row.status == '1'">{{row.updateTime}}</span>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <pagination
  114. v-show="tableData.total > 0"
  115. :limit.sync="queryParams.size"
  116. :page.sync="queryParams.current"
  117. :total="Number(tableData.total)"
  118. @pagination="fetch"
  119. />
  120. <tenant-edit
  121. ref="edit"
  122. :dialog-visible="dialog.isVisible"
  123. :title="dialog.title"
  124. @close="editClose"
  125. @success="editSuccess"
  126. />
  127. <tenant-view
  128. ref="view"
  129. :dialog-visible="tenantViewVisible"
  130. @close="viewClose"
  131. />
  132. <el-dialog
  133. v-el-drag-dialog
  134. :close-on-click-modal="false"
  135. :close-on-press-escape="true"
  136. title="预览"
  137. width="80%"
  138. top="50px"
  139. :visible.sync="preview.isVisible"
  140. >
  141. <el-scrollbar>
  142. <div v-html="preview.context" />
  143. </el-scrollbar>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. import Pagination from "@/components/Pagination"
  149. import TenantEdit from "./components/Edit"
  150. import TenantView from "./components/View"
  151. // 【锁定记录、出入库记录】-API
  152. //import lockingRecordApi from "@/api/lineSideLibrary/lockingRecord"
  153. import warnLogApi from "@/api/lineSideLibrary/warnLog"
  154. import elDragDialog from '@/directive/el-drag-dialog'
  155. import { downloadFile, initEnums, initDicts, initQueryParams } from '@/utils/commons'
  156. import axios from 'axios'
  157. export default {
  158. name: "InOutRecord",
  159. directives: { elDragDialog },
  160. components: { Pagination, TenantEdit, TenantView },
  161. props: {
  162. },
  163. data () {
  164. return {
  165. audioStatus: [],
  166. dialog: {
  167. isVisible: false,
  168. title: ""
  169. },
  170. preview: {
  171. isVisible: false,
  172. context: ''
  173. },
  174. tenantViewVisible: false,
  175. tableKey: 0,
  176. queryParams: initQueryParams({}),
  177. selection: [],
  178. loading: false,
  179. tableData: {
  180. total: 0
  181. },
  182. dicts: {
  183. NATION: {}
  184. },
  185. enums: {
  186. TenantTypeEnum: {},
  187. TenantStatusEnum: {}
  188. },
  189. pickerOptions: {
  190. shortcuts: [{
  191. text: '最近一周',
  192. onClick(picker) {
  193. const end = new Date();
  194. const start = new Date();
  195. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  196. picker.$emit('pick', [start, end]);
  197. }
  198. }, {
  199. text: '最近一个月',
  200. onClick(picker) {
  201. const end = new Date();
  202. const start = new Date();
  203. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  204. picker.$emit('pick', [start, end]);
  205. }
  206. }, {
  207. text: '最近三个月',
  208. onClick(picker) {
  209. const end = new Date();
  210. const start = new Date();
  211. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  212. picker.$emit('pick', [start, end]);
  213. }
  214. }]
  215. }
  216. }
  217. },
  218. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  219. created() {
  220. // 调用常量-审核状态
  221. this.audioStatus = this.$constWKS.OPTTYPE
  222. // 加载【字典】
  223. initDicts(['NATION'], this.dicts);
  224. // 加载列表数据
  225. this.fetch()
  226. },
  227. computed: {
  228. currentUser () {
  229. return this.$store.state.account.user
  230. },
  231. nationList() {
  232. return convertEnum(this.dicts.NATION)
  233. }
  234. },
  235. mounted () {
  236. },
  237. methods: {
  238. viewClose () {
  239. this.tenantViewVisible = false
  240. },
  241. editClose () {
  242. this.dialog.isVisible = false
  243. },
  244. editSuccess () {
  245. this.search()
  246. },
  247. onSelectChange (selection) {
  248. this.selection = selection
  249. },
  250. search () {
  251. this.fetch({
  252. ...this.queryParams
  253. })
  254. },
  255. reset () {
  256. this.queryParams = initQueryParams({})
  257. this.$refs.table.clearSort()
  258. this.$refs.table.clearFilter()
  259. this.search()
  260. },
  261. add () {
  262. this.$refs.edit.type = "add"
  263. this.$refs.edit.setTenant(false, this.dicts)
  264. this.dialog.title = this.$t("common.add")
  265. this.dialog.isVisible = true
  266. },
  267. singleDelete (row) {
  268. this.$refs.table.clearSelection()
  269. this.$refs.table.toggleRowSelection(row, true)
  270. this.batchDelete()
  271. },
  272. batchDelete () {
  273. if (!this.selection.length) {
  274. this.$message({
  275. message: this.$t("tips.noDataSelected"),
  276. type: "warning"
  277. })
  278. return
  279. }
  280. this.$confirm(this.$t("developer.tips.wareTips"), this.$t("common.tips"), {
  281. distinguishCancelAndClose: true,
  282. confirmButtonText: this.$t("common.confirm"),
  283. cancelButtonText: this.$t("common.cancel"),
  284. type: "warning"
  285. }).then(() => {
  286. const ids = []
  287. this.selection.forEach(item => {
  288. ids.push(item.id)
  289. })
  290. this.delete(ids)
  291. }).catch(() => {})
  292. },
  293. clearSelections () {
  294. this.$refs.table.clearSelection()
  295. },
  296. marking(){
  297. if (!this.selection.length) {
  298. this.$message({
  299. message: this.$t("tips.noDataSelected"),
  300. type: "warning"
  301. })
  302. return false
  303. }
  304. const ids = []
  305. this.selection.forEach(item => {
  306. ids.push(item.id)
  307. })
  308. this.updateStatus(ids)
  309. },
  310. updateStatus(ids){
  311. warnLogApi.updateStatus({ids: ids}).then(response => {
  312. const res = response.data
  313. if (res.isSuccess) {
  314. this.$message({
  315. message: '标注成功',
  316. type: "success"
  317. })
  318. this.search()
  319. }
  320. })
  321. },
  322. delete (ids) {
  323. warnLogApi.remove({ ids: ids }).then(response => {
  324. const res = response.data
  325. if (res.isSuccess) {
  326. this.$message({
  327. message: this.$t("tips.deleteSuccess"),
  328. type: "success"
  329. })
  330. this.search()
  331. // 清理已经删除的数据
  332. this.$refs.table.clearSelection()
  333. }
  334. })
  335. },
  336. view (row) {
  337. this.$refs.view.setTenant(row)
  338. this.tenantViewVisible = true
  339. },
  340. // 【修改】表头上Btn-事件
  341. editOne() {
  342. if (!this.selection.length) {
  343. this.$message({
  344. message: this.$t("tips.noDataSelected"),
  345. type: "warning"
  346. })
  347. return
  348. }
  349. if (this.selection.length > 1) {
  350. this.$message({
  351. message: this.$t("tips.mustOne"),
  352. type: "warning"
  353. })
  354. return
  355. }
  356. this.edit(this.selection[0]);
  357. },
  358. edit (row) {
  359. this.$refs.edit.setTenant(row, this.dicts)
  360. this.$refs.edit.type = "edit"
  361. this.dialog.title = this.$t("common.edit")
  362. this.dialog.isVisible = true
  363. },
  364. fetch (params = {}) {
  365. this.loading = true
  366. if (this.queryParams.timeRange) {
  367. this.queryParams.map.createTime_st = this.queryParams.timeRange[0]
  368. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]
  369. }
  370. this.queryParams.current = params.current ? params.current : this.queryParams.current
  371. this.queryParams.size = params.size ? params.size : this.queryParams.size
  372. // 固定参数:dataStatus = 1-入库/出库,2-解锁/锁定
  373. //this.queryParams.model.dataStatus = '1'
  374. warnLogApi.page(this.queryParams).then(response => {
  375. const res = response.data
  376. if (res.isSuccess) {
  377. this.tableData = res.data
  378. }
  379. // eslint-disable-next-line no-return-assign
  380. }).finally(() => this.loading = false)
  381. },
  382. cellClick (row, column) {
  383. if (column['columnKey'] === "operation") {
  384. return
  385. }
  386. let flag = false
  387. this.selection.forEach((item) => {
  388. if (item.id === row.id) {
  389. flag = true
  390. this.$refs.table.toggleRowSelection(row)
  391. }
  392. })
  393. if (!flag) {
  394. this.$refs.table.toggleRowSelection(row, true)
  395. }
  396. }
  397. }
  398. }
  399. </script>
  400. <style lang="scss" scoped></style>