item-list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="datasource"
  8. height="calc(100vh - 265px)"
  9. full-height="calc(100vh - 116px)"
  10. tool-class="ele-toolbar-form"
  11. cache-key="systemOrgUserTable"
  12. >
  13. <!-- 表头工具栏 -->
  14. <template v-slot:toolbar>
  15. <item-search @search="reload"> </item-search>
  16. </template>
  17. <!-- 操作列 -->
  18. <template v-slot:action="{ row }">
  19. <el-link
  20. type="primary"
  21. :underline="false"
  22. icon="el-icon-edit"
  23. @click="openEdit(row)"
  24. >
  25. 编辑
  26. </el-link>
  27. <el-link
  28. v-if="row.loginName"
  29. type="primary"
  30. :underline="false"
  31. icon="el-icon-unlock"
  32. @click="toUnBind(row)"
  33. >
  34. 克隆
  35. </el-link>
  36. <el-popconfirm
  37. class="ele-action"
  38. title="确定要删除此物品?"
  39. @confirm="remove(row)"
  40. >
  41. <template v-slot:reference>
  42. <el-link type="danger" :underline="false" icon="el-icon-delete">
  43. 删除
  44. </el-link>
  45. </template>
  46. </el-popconfirm>
  47. </template>
  48. </ele-pro-table>
  49. </div>
  50. </template>
  51. <script>
  52. import ItemSearch from './item-search.vue';
  53. // import {
  54. // getUserPage,
  55. // removePersonnel,
  56. // unbindLoginName
  57. // } from '@/api/system/organization';
  58. import { getList, removeItem } from '@/api/classifyManage/itemInformation';
  59. export default {
  60. components: { ItemSearch },
  61. props: {
  62. // 机构id
  63. organizationId: [Number, String],
  64. // 全部机构
  65. organizationList: Array,
  66. current: {
  67. type: Object,
  68. default: () => ({})
  69. }
  70. },
  71. data () {
  72. return {};
  73. },
  74. computed: {
  75. // 表格列配置
  76. columns () {
  77. const privateColumn = [];
  78. if (!['8', '1', '2', '5', '6', '7'].includes(this.current?.type)) {
  79. privateColumn.push({
  80. prop: 'brandNum',
  81. label: '牌号',
  82. showOverflowTooltip: true
  83. });
  84. }
  85. if (!['3'].includes(this.current?.type)) {
  86. privateColumn.push({
  87. prop: 'modelType',
  88. label: '型号',
  89. showOverflowTooltip: true
  90. });
  91. }
  92. if (!['3', '4'].includes(this.current?.type)) {
  93. privateColumn.push({
  94. prop: 'specification',
  95. label: '规格',
  96. showOverflowTooltip: true
  97. });
  98. }
  99. return [
  100. {
  101. columnKey: 'index',
  102. type: 'index',
  103. width: 45,
  104. align: 'center',
  105. showOverflowTooltip: true,
  106. fixed: 'left'
  107. },
  108. {
  109. prop: 'informationCode',
  110. label: '物品编码',
  111. showOverflowTooltip: true
  112. },
  113. {
  114. prop: 'informationName',
  115. label: '物品名称',
  116. showOverflowTooltip: true
  117. },
  118. {
  119. prop: 'classificationCode',
  120. label: '物品类型',
  121. showOverflowTooltip: true
  122. },
  123. ...privateColumn,
  124. {
  125. prop: 'measuringUnit',
  126. label: '计量单位',
  127. sortable: 'custom',
  128. showOverflowTooltip: true
  129. },
  130. {
  131. prop: 'packingUnit',
  132. label: '包装单位',
  133. align: 'center'
  134. },
  135. {
  136. prop: 'classificationUrl',
  137. label: '分类',
  138. showOverflowTooltip: true
  139. },
  140. {
  141. columnKey: 'action',
  142. label: '操作',
  143. width: 200,
  144. align: 'left',
  145. resizable: false,
  146. slot: 'action'
  147. }
  148. ];
  149. }
  150. },
  151. methods: {
  152. /* 表格数据源 */
  153. datasource ({ page, limit, where }) {
  154. return getList({
  155. ...where,
  156. pageNum: page,
  157. size: limit
  158. });
  159. },
  160. /* 刷新表格 */
  161. reload (where) {
  162. this.$refs.table.reload({ pageNum: 1, where: where });
  163. },
  164. /* 显示编辑 */
  165. openEdit (row) {},
  166. // 解除绑定
  167. toUnBind (row) {
  168. const loading = this.$loading({ lock: true });
  169. unbindLoginName(row.id)
  170. .then((res) => {
  171. loading.close();
  172. this.$message.success('解绑成功');
  173. this.reload();
  174. })
  175. .catch((e) => {
  176. loading.close();
  177. this.$message.error(e.message);
  178. });
  179. },
  180. /* 删除 */
  181. remove (row) {
  182. const loading = this.$loading({ lock: true });
  183. removeItem(id).then((msg) => {
  184. loading.close();
  185. this.$message.success(msg);
  186. this.reload();
  187. });
  188. },
  189. /* 更改状态 */
  190. editStatus (row) {
  191. const loading = this.$loading({ lock: true });
  192. updateUserStatus(row.userId, row.status)
  193. .then((msg) => {
  194. loading.close();
  195. this.$message.success(msg);
  196. })
  197. .catch((e) => {
  198. loading.close();
  199. row.status = !row.status ? 1 : 0;
  200. this.$message.error(e.message);
  201. });
  202. }
  203. },
  204. watch: {
  205. // 监听机构id变化
  206. current: {
  207. handler () {
  208. console.log(this.current);
  209. this.reload();
  210. }
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="scss" scoped></style>