index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <!-- 搜索工作栏 -->
  3. <ContentWrap>
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="编码分类名称" prop="name" label-width="100px">
  12. <el-input
  13. v-model="queryParams.name"
  14. placeholder="请输入编码分类名称"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="编码分类状态" prop="status" label-width="100px">
  21. <el-select
  22. v-model="queryParams.status"
  23. placeholder="请选择编码分类状态"
  24. clearable
  25. class="!w-240px"
  26. >
  27. <el-option
  28. v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
  29. :key="dict.value"
  30. :label="dict.label"
  31. :value="dict.value"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  37. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  38. <el-button
  39. type="primary"
  40. plain
  41. @click="openForm('create')"
  42. v-hasPermi="['iot:product-classify:create']"
  43. >
  44. <Icon icon="ep:plus" class="mr-5px" /> 新增
  45. </el-button>
  46. <el-button type="danger" plain @click="toggleExpandAll">
  47. <Icon icon="ep:sort" class="mr-5px" /> 展开/折叠
  48. </el-button>
  49. </el-form-item>
  50. </el-form>
  51. </ContentWrap>
  52. <!-- 列表 -->
  53. <ContentWrap>
  54. <el-table
  55. v-loading="loading"
  56. :data="list"
  57. row-key="id"
  58. :default-expand-all="isExpandAll"
  59. v-if="refreshTable"
  60. @row-click="handleClick"
  61. >
  62. <el-table-column prop="name" label="编码分类名称" />
  63. <el-table-column prop="code" label="编码分类编码" />
  64. <el-table-column prop="sort" label="排序" />
  65. <el-table-column prop="company" label="所属公司" >
  66. <template #default="scope">
  67. <span v-if="scope.row.company==='RH'" style="font-weight: bold">瑞恒兴域</span>
  68. <span v-if="scope.row.company==='RD'" style="font-weight: bold">四川瑞都</span>
  69. <span v-if="scope.row.company==='RY'" style="font-weight: bold">瑞鹰国际</span>
  70. <span v-if="scope.row.company==='DF'" style="font-weight: bold">东方石油</span>
  71. <span v-if="scope.row.company==='RL'" style="font-weight: bold">瑞霖技术</span>
  72. <span v-if="scope.row.company==='RQ'" style="font-weight: bold">瑞气能源</span>
  73. <span v-if="scope.row.company==='DM'" style="font-weight: bold">DMCC 中东</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop="status" label="状态">
  77. <template #default="scope">
  78. <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
  79. </template>
  80. </el-table-column>
  81. <el-table-column prop="remark" label="备注" />
  82. <el-table-column
  83. label="创建时间"
  84. align="center"
  85. prop="createTime"
  86. width="180"
  87. :formatter="dateFormatter"
  88. />
  89. <el-table-column label="操作" align="center">
  90. <template #default="scope">
  91. <el-button
  92. link
  93. type="primary"
  94. @click="openForm('update', scope.row.id)"
  95. v-hasPermi="['iot:product-classify:update']"
  96. >
  97. 修改
  98. </el-button>
  99. <el-button
  100. link
  101. type="danger"
  102. @click="handleDelete(scope.row.id)"
  103. v-hasPermi="['iot:product-classify:delete']"
  104. >
  105. 删除
  106. </el-button>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. </ContentWrap>
  111. <!-- 表单弹窗:添加/修改 -->
  112. <YfClassifyForm ref="formRef" @success="getList" />
  113. </template>
  114. <script lang="ts" setup>
  115. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  116. import { dateFormatter } from '@/utils/formatTime'
  117. import { handleTree } from '@/utils/tree'
  118. import * as YfClassifyApi from '@/api/pms/yfclass'
  119. import YfClassifyForm from './YfClassifyForm.vue'
  120. import {IotYfClassifyApi} from "@/api/pms/yfclass";
  121. defineOptions({ name: 'IotProductClassify' })
  122. const message = useMessage() // 消息弹窗
  123. const { t } = useI18n() // 国际化
  124. const loading = ref(true) // 列表的加载中
  125. const list = ref() // 列表的数据
  126. const queryParams = reactive({
  127. pageNo: 1,
  128. pageSize: 100,
  129. name: undefined,
  130. status: undefined
  131. })
  132. const queryFormRef = ref() // 搜索的表单
  133. const isExpandAll = ref(true) // 是否展开,默认全部展开
  134. const refreshTable = ref(true) // 重新渲染表格状态
  135. const parentId = ref('')
  136. const handleClick = (node: {}) => {
  137. parentId.value = node.id
  138. }
  139. /** 查询编码分类列表 */
  140. const getList = async () => {
  141. loading.value = true
  142. try {
  143. const data = await YfClassifyApi.IotYfClassifyApi.getIotYfClassifyPage(queryParams)
  144. list.value = handleTree(data)
  145. } finally {
  146. loading.value = false
  147. }
  148. }
  149. /** 展开/折叠操作 */
  150. const toggleExpandAll = () => {
  151. refreshTable.value = false
  152. isExpandAll.value = !isExpandAll.value
  153. nextTick(() => {
  154. refreshTable.value = true
  155. })
  156. }
  157. /** 搜索按钮操作 */
  158. const handleQuery = () => {
  159. getList()
  160. }
  161. /** 重置按钮操作 */
  162. const resetQuery = () => {
  163. queryParams.pageNo = 1
  164. queryFormRef.value.resetFields()
  165. handleQuery()
  166. }
  167. /** 添加/修改操作 */
  168. const formRef = ref()
  169. const openForm = (type: string, id?: number, parent: number) => {
  170. parent = parentId.value
  171. formRef.value.open(type, id, parent)
  172. }
  173. /** 删除按钮操作 */
  174. const handleDelete = async (id: number) => {
  175. try {
  176. // 删除的二次确认
  177. await message.delConfirm()
  178. // 发起删除
  179. await IotYfClassifyApi.deleteIotYfClassify(id)
  180. message.success(t('common.delSuccess'))
  181. // 刷新列表
  182. await getList()
  183. } catch {}
  184. }
  185. /** 初始化 **/
  186. onMounted(async () => {
  187. await getList()
  188. // 获取用户列表
  189. //userList.value = await UserApi.getSimpleUserList()
  190. })
  191. </script>
  192. <style scoped>
  193. /* 全局样式或 scoped 穿透 */
  194. :deep(.el-table__body tr) {
  195. cursor: pointer; /* 手型光标 */
  196. }
  197. :deep(.el-table__body tr:hover) {
  198. cursor: pointer;
  199. }
  200. </style>