Index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索模块 -->
  4. <div class="filter-container">
  5. <span>
  6. <span>刀柄名称:</span>
  7. <el-input v-model="queryParams.model.handleName" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
  8. </span>
  9. <span>
  10. <span>刀柄编码:</span>
  11. <el-input v-model="queryParams.model.handleCode" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
  12. </span>
  13. <span style="margin-left: 15px;">
  14. <el-button plain type="primary" icon="el-icon-search" size="medium" @click="search">
  15. {{ $t("table.search") }}
  16. </el-button>
  17. <el-button plain type="warning" icon="el-icon-refresh" size="medium" @click="reset">
  18. {{ $t("table.reset") }}
  19. </el-button>
  20. </span>
  21. </div>
  22. <!-- 功能按钮 -->
  23. <el-row class="filter-container">
  24. <el-col>
  25. <el-button type="primary" icon="el-icon-plus" size="medium" v-has-permission="['goodsShelves:add']" @click="add">{{ $t("common.add") }}</el-button>
  26. <el-button type="success" icon="el-icon-edit" size="medium" v-has-permission="['goodsShelves:update']" @click="editOne">
  27. {{ $t("common.edit") }}
  28. </el-button>
  29. <el-button type="danger" icon="el-icon-delete" size="medium" v-has-permission="['goodsShelves:delete']" @click="batchDelete">
  30. {{ $t("table.delete") }}
  31. </el-button>
  32. </el-col>
  33. </el-row>
  34. <!-- 列表数据 -->
  35. <el-table
  36. :key="tableKey"
  37. ref="table"
  38. v-loading="loading"
  39. :data="tableData.records"
  40. border
  41. fit
  42. row-key="id"
  43. style="width: 100%;"
  44. :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
  45. @selection-change="onSelectChange"
  46. @cell-click="cellClick"
  47. >
  48. <el-table-column label='' width="50" align="center"></el-table-column>
  49. <el-table-column align="center" type="selection" width="50" :reserve-selection="true" />
  50. <el-table-column prop="handleName" :label='"刀柄名称"' :show-overflow-tooltip="true"></el-table-column>
  51. <el-table-column prop="handleCode" :label='"刀柄编号"' :show-overflow-tooltip="true" ></el-table-column>
  52. <el-table-column prop="handleMaterial" :label='"刀柄材料"' :show-overflow-tooltip="true" ></el-table-column>
  53. <el-table-column prop="handleLength" :label='"刀柄长度"' :show-overflow-tooltip="true" ></el-table-column>
  54. <el-table-column prop="manufacturer" :label='"生产厂家"' :show-overflow-tooltip="true" ></el-table-column>
  55. <el-table-column prop="createTime" :label='$t("lineSide.table.toolManagement.createTime")' width="180px"></el-table-column>
  56. <el-table-column
  57. :label="$t('table.operation')"
  58. fixed="right"
  59. align="center"
  60. column-key="operation"
  61. width="140px"
  62. >
  63. <template slot-scope="{ row }">
  64. <el-tooltip class="item" :content='$t("common.edit")' effect="dark" placement="top-start">
  65. <i
  66. class="el-icon-edit table-operation"
  67. style="color: #2db7f5;"
  68. @click="edit(row)"
  69. />
  70. </el-tooltip>
  71. <el-tooltip class="item" :content='$t("common.delete")' effect="dark" placement="top-start">
  72. <i
  73. class="el-icon-delete table-operation"
  74. style="color: #f50;"
  75. @click="singleDelete(row)"
  76. />
  77. </el-tooltip>
  78. <el-tooltip class="item" :content='$t("common.frozen")' effect="dark" placement="top-start">
  79. <i
  80. class="el-icon-warning-outline table-operation"
  81. style="color: #f50;"
  82. @click="dongJieRow(row)"
  83. />
  84. </el-tooltip>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <pagination
  89. v-show="tableData.total > 0"
  90. :limit.sync="queryParams.size"
  91. :page.sync="queryParams.current"
  92. :total="Number(tableData.total)"
  93. @pagination="fetch"
  94. />
  95. <tenant-edit
  96. ref="edit"
  97. :dialog-visible="dialog.isVisible"
  98. :title="dialog.title"
  99. @close="editClose"
  100. @success="editSuccess"
  101. />
  102. <tenant-view
  103. ref="view"
  104. :dialog-visible="tenantViewVisible"
  105. @close="viewClose"
  106. />
  107. <el-dialog
  108. v-el-drag-dialog
  109. :close-on-click-modal="false"
  110. :close-on-press-escape="true"
  111. :title='$t("common.preview")'
  112. width="80%"
  113. top="50px"
  114. :visible.sync="preview.isVisible"
  115. >
  116. <el-scrollbar>
  117. <div v-html="preview.context" />
  118. </el-scrollbar>
  119. </el-dialog>
  120. </div>
  121. </template>
  122. <script>
  123. import Pagination from "@/components/Pagination"
  124. import TenantEdit from "./components/Edit"
  125. import TenantView from "./components/View"
  126. // 【货架管理】-API
  127. import toolHandleApi from "@/api/modelingCenter/toolHandle"
  128. import elDragDialog from '@/directive/el-drag-dialog'
  129. import { downloadFile, initEnums, initDicts, initQueryParams } from '@/utils/commons'
  130. // 加载工具类
  131. import { convertEnum, createTreeData } from '@/utils/utils'
  132. import axios from 'axios'
  133. export default {
  134. name: "GoodsShelvesMgr",
  135. directives: { elDragDialog },
  136. components: { Pagination, TenantEdit, TenantView },
  137. props: {
  138. },
  139. data () {
  140. return {
  141. audioStatus: [],
  142. dialog: {
  143. isVisible: false,
  144. title: ""
  145. },
  146. preview: {
  147. isVisible: false,
  148. context: ''
  149. },
  150. tenantViewVisible: false,
  151. tableKey: 0,
  152. queryParams: initQueryParams({}),
  153. selection: [],
  154. loading: false,
  155. tableData: {
  156. total: 0
  157. },
  158. dicts: {
  159. NATION: {}
  160. },
  161. enums: {
  162. TenantTypeEnum: {},
  163. TenantStatusEnum: {}
  164. }
  165. }
  166. },
  167. // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
  168. created() {
  169. // 调用常量-审核状态
  170. this.audioStatus = this.$constWKS.STATUSORTHERLIST
  171. // 加载【字典】
  172. initDicts(['NATION'], this.dicts);
  173. // 加载列表数据
  174. this.fetch()
  175. },
  176. computed: {
  177. /* 转树形数据 */
  178. optionData() {
  179. if(this.tableData.records){
  180. let cloneData = JSON.parse(JSON.stringify(this.tableData.records)) // 对源数据深度克隆
  181. if(cloneData){
  182. return createTreeData(cloneData)
  183. }
  184. }
  185. },
  186. currentUser () {
  187. return this.$store.state.account.user
  188. },
  189. nationList() {
  190. return convertEnum(this.dicts.NATION)
  191. }
  192. },
  193. mounted () {
  194. },
  195. methods: {
  196. // 【启用/冻结】按钮-事件
  197. updateActiveStatus(status){
  198. if (!this.selection.length) {
  199. this.$message({
  200. message: this.$t("tips.noDataSelected"),
  201. type: "warning"
  202. })
  203. return
  204. }
  205. if (this.selection.length > 1) {
  206. this.$message({
  207. message: this.$t("tips.mustOne"),
  208. type: "warning"
  209. })
  210. return
  211. }
  212. // 传值
  213. let obj = {};
  214. obj = this.selection[0];
  215. obj.status = status;
  216. // 调用接口后的提示信息
  217. let msg = this.$t("tips.frozen")
  218. if(status == "1"){
  219. msg = this.$t("tips.enable")
  220. }
  221. toolHandleApi.update(obj).then(response => {
  222. if (response.status == 200) {
  223. this.$message({
  224. message: msg,
  225. type: "success"
  226. })
  227. // 重新查询列表数据
  228. this.search()
  229. }
  230. })
  231. },
  232. // 【冻结】-Table的Row操作事件
  233. dongJieRow(row) {
  234. // 传值
  235. let obj = {};
  236. obj = row;
  237. obj.status = "0";
  238. toolHandleApi.update(obj).then(response => {
  239. if (response.status == 200) {
  240. this.$message({
  241. message: this.$t("tips.frozen"),
  242. type: "success"
  243. })
  244. // 重新查询列表数据
  245. this.search()
  246. }
  247. })
  248. },
  249. viewClose () {
  250. this.tenantViewVisible = false
  251. },
  252. editClose () {
  253. this.dialog.isVisible = false
  254. },
  255. editSuccess () {
  256. this.search()
  257. },
  258. onSelectChange (selection) {
  259. this.selection = selection
  260. },
  261. search () {
  262. this.fetch({
  263. ...this.queryParams
  264. })
  265. },
  266. reset () {
  267. this.queryParams = initQueryParams({})
  268. this.$refs.table.clearSort()
  269. this.$refs.table.clearFilter()
  270. this.search()
  271. },
  272. add () {
  273. this.$refs.edit.type = "add"
  274. this.$refs.edit.setTenant(false, this.dicts)
  275. // 【上级货架】数据设置
  276. this.$refs.edit.list = this.tableData.records
  277. this.dialog.title = this.$t("common.add")
  278. this.dialog.isVisible = true
  279. },
  280. singleDelete (row) {
  281. this.$refs.table.clearSelection()
  282. this.$refs.table.toggleRowSelection(row, true)
  283. this.batchDelete()
  284. },
  285. batchDelete () {
  286. if (!this.selection.length) {
  287. this.$message({
  288. message: this.$t("tips.noDataSelected"),
  289. type: "warning"
  290. })
  291. return
  292. }
  293. const readonlyIndex = this.selection.findIndex(item => item.readonly)
  294. if (readonlyIndex > -1) {
  295. this.$message({
  296. message: this.$t("tips.systemData"),
  297. type: "warning"
  298. })
  299. return
  300. }
  301. this.$confirm(this.$t("lineSide.tips.shelvsTips"), this.$t("common.tips"), {
  302. distinguishCancelAndClose: true,
  303. confirmButtonText: this.$t("common.confirm"),
  304. cancelButtonText: this.$t("common.cancel"),
  305. type: "warning"
  306. }).then(() => {
  307. const ids = []
  308. let contain = false
  309. this.selection.forEach(item => {
  310. if (item.readonly) {
  311. contain = true
  312. return
  313. }
  314. ids.push(item.id)
  315. })
  316. if (contain) {
  317. this.$message({
  318. message: this.$t("tips.systemData"),
  319. type: "warning"
  320. })
  321. } else {
  322. this.delete(ids)
  323. }
  324. }).catch(() => {})
  325. },
  326. clearSelections () {
  327. this.$refs.table.clearSelection()
  328. },
  329. delete (ids) {
  330. toolHandleApi.remove({ ids: ids }).then(response => {
  331. const res = response.data
  332. if (res.isSuccess) {
  333. this.$message({
  334. message: this.$t("tips.deleteSuccess"),
  335. type: "success"
  336. })
  337. this.search()
  338. // 清理已经删除的数据
  339. this.$refs.table.clearSelection()
  340. }
  341. })
  342. },
  343. view (row) {
  344. this.$refs.view.setTenant(row)
  345. this.tenantViewVisible = true
  346. },
  347. // 【修改】表头上Btn-事件
  348. editOne() {
  349. if (!this.selection.length) {
  350. this.$message({
  351. message: this.$t("tips.unSelected"),
  352. type: "warning"
  353. })
  354. return
  355. }
  356. if (this.selection.length > 1) {
  357. this.$message({
  358. message: this.$t("tips.mustOne"),
  359. type: "warning"
  360. })
  361. return
  362. }
  363. this.edit(this.selection[0]);
  364. },
  365. edit (row) {
  366. if (row.readonly) {
  367. this.$message({
  368. message: this.$t("tips.systemData"),
  369. type: "warning"
  370. })
  371. return
  372. }
  373. this.$refs.edit.setTenant(row, this.dicts)
  374. this.$refs.edit.type = "edit"
  375. this.dialog.title = this.$t("common.edit")
  376. // 【上级货架】数据设置
  377. this.$refs.edit.list = this.tableData.records
  378. this.dialog.isVisible = true
  379. },
  380. fetch (params = {}) {
  381. this.loading = true
  382. if (this.queryParams.timeRange) {
  383. this.queryParams.map.createTime_st = this.queryParams.timeRange[0]
  384. this.queryParams.map.createTime_ed = this.queryParams.timeRange[1]
  385. }
  386. this.queryParams.current = params.current ? params.current : this.queryParams.current
  387. this.queryParams.size = params.size ? params.size : this.queryParams.size
  388. toolHandleApi.page(this.queryParams).then(response => {
  389. const res = response.data
  390. if (res.isSuccess) {
  391. this.tableData = res.data
  392. }
  393. // eslint-disable-next-line no-return-assign
  394. }).finally(() => this.loading = false)
  395. },
  396. cellClick (row, column) {
  397. if (column['columnKey'] === "operation") {
  398. return
  399. }
  400. let flag = false
  401. this.selection.forEach((item) => {
  402. if (item.id === row.id) {
  403. flag = true
  404. this.$refs.table.toggleRowSelection(row)
  405. }
  406. })
  407. if (!flag) {
  408. this.$refs.table.toggleRowSelection(row, true)
  409. }
  410. },
  411. getTagType(toolType) {
  412. switch (toolType) {
  413. case '1':
  414. return 'success'; // 第一种类型的标签颜色
  415. case '2':
  416. return 'warning'; // 第二种类型的标签颜色
  417. case '3':
  418. return 'info'; // 第三种类型的标签颜色
  419. case '4':
  420. return 'danger'; // 第四种类型的标签颜色
  421. default:
  422. return 'default'; // 默认标签颜色,你可以根据需要修改
  423. }
  424. },
  425. getToolTypeText(toolType) {
  426. switch (toolType) {
  427. case '0':
  428. return this.$t('lineSide.common.central'); // 第一种类型的文本
  429. case '1':
  430. return this.$t('lineSide.common.lathe'); // 第二种类型的文本
  431. case '2':
  432. return '机器人随行货架'; // 第三种类型的文本
  433. case '3':
  434. return '机床刀具缓存库'; // 第四种类型的文本
  435. case '4':
  436. return '接驳位'; // 第四种类型的文本
  437. default:
  438. return ''; // 默认文本,你可以根据需要修改
  439. }
  440. }
  441. }
  442. }
  443. </script>
  444. <style lang="scss" scoped></style>