index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <search @search="reload"></search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. cache-key="systemRoleTable"
  11. :pageSize="20"
  12. >
  13. <!-- 表头工具栏 -->
  14. <template v-slot:toolbar>
  15. <el-button
  16. size="small"
  17. type="primary"
  18. icon="el-icon-plus"
  19. class="ele-btn-icon"
  20. @click="openEdit('', 'add')"
  21. >新建</el-button>
  22. </template>
  23. <template v-slot:code="{ row }">
  24. <el-link type="primary" :underline="false" @click="openEdit(row, 'view')">{{ row.code }}</el-link>
  25. </template>
  26. <template v-slot:action="{ row }">
  27. <el-link type="primary" v-if="row.source == 0" :underline="false" @click="openEdit(row, 'edit')">修改</el-link>
  28. <el-popconfirm
  29. v-if="row.source == 0"
  30. class="ele-action"
  31. title="确定要删除此配件记录吗?"
  32. @confirm="handleRemove(row)"
  33. >
  34. <template v-slot:reference>
  35. <el-link type="danger" :underline="false" icon="el-icon-delete">删除</el-link>
  36. </template>
  37. </el-popconfirm>
  38. </template>
  39. </ele-pro-table>
  40. </el-card>
  41. <!-- 新建或编辑弹窗 -->
  42. <accessoryDialog ref="accessoryDialog" @refresh="reload" />
  43. </div>
  44. </template>
  45. <script>
  46. import search from './components/search.vue';
  47. import accessoryDialog from './components/accessoryDialog.vue';
  48. import {
  49. accessoryPage,
  50. accessoryDelete
  51. // accessoryUpdate
  52. } from '@/api/salesServiceManagement/index';
  53. // import dictMixins from '@/mixins/dictMixins';
  54. export default {
  55. // mixins: [dictMixins],
  56. components: {
  57. search,
  58. accessoryDialog
  59. },
  60. data() {
  61. return {
  62. // 加载状态
  63. loading: false
  64. };
  65. },
  66. computed: {
  67. columns() {
  68. return [
  69. {
  70. columnKey: 'index',
  71. label: '序号',
  72. type: 'index',
  73. width: 55,
  74. align: 'center',
  75. showOverflowTooltip: true,
  76. fixed: 'left'
  77. },
  78. {
  79. slot: 'code',
  80. prop: 'code',
  81. label: '编码',
  82. align: 'center',
  83. showOverflowTooltip: true
  84. },
  85. {
  86. prop: 'orderCode',
  87. label: '工单编码',
  88. align: 'center',
  89. showOverflowTooltip: true
  90. },
  91. {
  92. prop: 'categoryLevelName',
  93. label: '物品分类',
  94. align: 'center',
  95. showOverflowTooltip: true,
  96. formatter: (row) => {
  97. if (!row.details) return '';
  98. let str = '';
  99. row.details.map((el, idx) => {
  100. if (idx + 1 == row.details.length) {
  101. str += el.categoryLevelName;
  102. } else {
  103. str = el.categoryLevelName
  104. ? str + '' + el.categoryLevelName + ','
  105. : str + '';
  106. }
  107. });
  108. return str;
  109. }
  110. },
  111. // + +关键字
  112. {
  113. prop: 'categoryName',
  114. label: '物品名称',
  115. align: 'center',
  116. showOverflowTooltip: true,
  117. formatter: (row) => {
  118. if (!row.details) return '';
  119. let str = '';
  120. row.details.map((el, idx) => {
  121. if (idx + 1 == row.details.length) {
  122. str += el.categoryName;
  123. } else {
  124. str = str + '' + el.categoryName + ',';
  125. }
  126. });
  127. return str;
  128. }
  129. },
  130. {
  131. prop: 'receivingDeptName',
  132. label: '领用部门',
  133. align: 'center',
  134. showOverflowTooltip: true
  135. },
  136. // + + 时间选择
  137. {
  138. prop: 'recipientName',
  139. label: '领用人',
  140. align: 'center',
  141. showOverflowTooltip: true
  142. },
  143. {
  144. prop: 'contactName',
  145. label: '客户名称',
  146. align: 'center',
  147. showOverflowTooltip: true
  148. },
  149. {
  150. prop: 'categoryName',
  151. label: '设备名称',
  152. align: 'center',
  153. showOverflowTooltip: true,
  154. formatter: (row) => {
  155. if (!row.deviceDetails) return '';
  156. let str = '';
  157. row.deviceDetails.map((el, idx) => {
  158. if (idx + 1 == row.deviceDetails.length) {
  159. str += el.categoryName;
  160. } else {
  161. str = str + '' + el.categoryName + ',';
  162. }
  163. });
  164. return str;
  165. }
  166. },
  167. {
  168. prop: 'createTime',
  169. label: '创建时间',
  170. align: 'center',
  171. showOverflowTooltip: true
  172. },
  173. {
  174. prop: 'usageTime',
  175. label: '使用时间',
  176. align: 'center',
  177. showOverflowTooltip: true
  178. },
  179. {
  180. columnKey: 'action',
  181. slot: 'action',
  182. label: '操作',
  183. align: 'center',
  184. width: 180,
  185. resizable: false,
  186. showOverflowTooltip: true
  187. }
  188. ];
  189. }
  190. },
  191. created() {},
  192. methods: {
  193. /* 表格数据源 */
  194. datasource({ page, limit, where, order }) {
  195. return accessoryPage({ pageNum: page, size: limit, ...where });
  196. },
  197. /* 刷新表格 */
  198. reload(where) {
  199. this.$refs.table.reload({ page: 1, where });
  200. },
  201. openEdit(row, type) {
  202. this.$refs.accessoryDialog.init(row, type);
  203. },
  204. handleRemove(row) {
  205. accessoryDelete([row.id]).then((res) => {
  206. if (res) {
  207. this.$message.success('操作成功!');
  208. this.reload();
  209. }
  210. });
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="scss" scoped></style>