maintenance.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <PageWrapper contentBackground>
  3. <template #footer>
  4. <a-tabs v-model:activeKey="tableType" @change="changeTable">
  5. <a-tab-pane :key="0" :tab="t('routes.spares.tableType.10')" />
  6. <a-tab-pane :key="1" :tab="t('routes.spares.tableType.21')" />
  7. <a-tab-pane :key="2" :tab="t('routes.spares.tableType.22')" /> </a-tabs
  8. ></template>
  9. <div class="desc-wrap-BasicTable">
  10. <BasicTable @register="registerTable">
  11. <template #action="{ record }">
  12. <TableAction
  13. stopButtonPropagation
  14. :actions="[
  15. {
  16. label: '详情',
  17. ifShow: getCheckPerm('work_detail'),
  18. onClick: handleDetail.bind(null, record),
  19. },
  20. {
  21. label: '添加备件',
  22. ifShow: getCheckPerm('maintenance_add') && tableType == 1 && record.status == 60,
  23. onClick: handleAdd.bind(null, record),
  24. },
  25. {
  26. label: '完成维修',
  27. ifShow: getCheckPerm('maintenance_finish') && tableType == 1 && record.status == 60,
  28. onClick: handleOut.bind(null, record),
  29. },
  30. {
  31. label: '检测登记',
  32. ifShow: getCheckPerm('maintenance_testing') && tableType == 0,
  33. onClick: handleRecover.bind(null, record),
  34. },
  35. {
  36. label: '修改定损',
  37. ifShow:
  38. getCheckPerm('maintenance_testing') && tableType == 1 && record.status == 20,
  39. onClick: handleRecover.bind(null, record),
  40. },
  41. ]"
  42. />
  43. </template>
  44. </BasicTable>
  45. <checkModel @update="reload" @register="registerRecovery" />
  46. <addAccessoryModel @update="reload" @register="registerAdd" />
  47. <outModal @update="reload" @register="registerOut" />
  48. <!-- ifShow: getCheckPerm('device-out') && !Boolean(record.outType), -->
  49. </div>
  50. </PageWrapper>
  51. </template>
  52. <script lang="ts">
  53. import { defineComponent, onMounted, ref, onActivated } from 'vue';
  54. import { PageWrapper } from '/@/components/Page';
  55. import {
  56. BasicTable,
  57. useTable,
  58. TableAction,
  59. BasicColumn,
  60. TableImg,
  61. FormProps,
  62. } from '/@/components/Table';
  63. import { Tabs } from 'ant-design-vue';
  64. import { operateSceneList } from '/@/api/operate';
  65. import { useI18n } from '/@/hooks/web/useI18n';
  66. import { usePermissionStore } from '/@/store/modules/permission';
  67. import checkModel from './checkModel.vue';
  68. import outModal from './outModal.vue';
  69. import addAccessoryModel from './addAccessoryModel.vue';
  70. import { useModal } from '/@/components/Modal';
  71. import { useRouter } from 'vue-router';
  72. import { saleOrderList, repairOrderList } from '/@/api/spares';
  73. export default defineComponent({
  74. name: '维修管理',
  75. components: {
  76. BasicTable,
  77. TableAction,
  78. TableImg,
  79. checkModel,
  80. outModal,
  81. PageWrapper,
  82. addAccessoryModel,
  83. [Tabs.name]: Tabs,
  84. [Tabs.TabPane.name]: Tabs.TabPane,
  85. },
  86. setup() {
  87. const { t } = useI18n();
  88. const permissionStore = usePermissionStore();
  89. const router = useRouter();
  90. const { getCheckPerm } = permissionStore;
  91. const tableType = ref<number>(0); //0 待接单,1待跟进,2已完结
  92. onMounted(() => {
  93. // console.log(router.currentRoute.value.params.id);
  94. });
  95. const columns: BasicColumn[] = [
  96. {
  97. title: '报修日期',
  98. dataIndex: 'createTime',
  99. width: 180,
  100. },
  101. {
  102. title: '客户名称',
  103. dataIndex: 'companyName',
  104. width: 80,
  105. },
  106. {
  107. title: '产品类型',
  108. dataIndex: 'cameraType',
  109. width: 80,
  110. customRender: ({ record }) => {
  111. return t(`routes.scene.tableType.${record.cameraType}`);
  112. },
  113. },
  114. {
  115. title: '产品SN码',
  116. dataIndex: 'cameraSnCode',
  117. width: 100,
  118. },
  119. {
  120. title: '故障描述',
  121. dataIndex: 'faultMsg',
  122. width: 100,
  123. },
  124. {
  125. title: '售后工程师',
  126. dataIndex: 'saleName',
  127. width: 100,
  128. },
  129. {
  130. title: '接单日期',
  131. dataIndex: 'orderReceivingTime',
  132. width: 100,
  133. },
  134. {
  135. title: '状态',
  136. dataIndex: 'status',
  137. width: 100,
  138. customRender: ({ record }) => {
  139. return t(`routes.spares.tableType.${record.status || 0}`);
  140. },
  141. },
  142. {
  143. title: '工单号',
  144. dataIndex: 'repairId',
  145. width: 150,
  146. },
  147. {
  148. title: t('common.operating'),
  149. dataIndex: 'action',
  150. slots: { customRender: 'action' },
  151. ifShow: true,
  152. fixed: 'right',
  153. flag: 'ACTION',
  154. width: 200,
  155. },
  156. ];
  157. const searchForm: Partial<FormProps> = {
  158. labelWidth: 120,
  159. schemas: [
  160. {
  161. field: 'cameraType',
  162. label: '设备类型',
  163. component: 'Select',
  164. componentProps: {
  165. options: [
  166. {
  167. label: t('routes.scene.tableType.0'),
  168. value: '0',
  169. },
  170. {
  171. label: t('routes.scene.tableType.1'),
  172. value: '1',
  173. },
  174. {
  175. label: t('routes.scene.tableType.2'),
  176. value: '2',
  177. },
  178. {
  179. label: t('routes.scene.tableType.3'),
  180. value: '3',
  181. },
  182. ],
  183. },
  184. colProps: {
  185. xl: 6,
  186. xxl: 6,
  187. },
  188. },
  189. {
  190. field: 'cameraSnCode',
  191. component: 'Input',
  192. label: t('routes.device.snCode'),
  193. colProps: {
  194. xl: 7,
  195. xxl: 7,
  196. },
  197. },
  198. {
  199. field: 'repairId',
  200. component: 'Input',
  201. label: '工单号',
  202. colProps: {
  203. xl: 7,
  204. xxl: 7,
  205. },
  206. },
  207. ],
  208. };
  209. const [registerRecovery, { openModal }] = useModal();
  210. const [registerOut, { openModal: openOutModal }] = useModal();
  211. const [registerAdd, { openModal: openAddModal }] = useModal();
  212. const [registerTable, { reload }] = useTable({
  213. api: repairOrderList,
  214. columns: columns,
  215. useSearchForm: true,
  216. searchInfo: { statusParam: tableType },
  217. formConfig: searchForm,
  218. showTableSetting: true,
  219. showIndexColumn: false,
  220. fetchSetting: {
  221. pageField: 'pageNum',
  222. sizeField: 'pageSize',
  223. listField: 'list',
  224. totalField: 'total',
  225. },
  226. canResize: false,
  227. });
  228. onActivated(() => {
  229. reload();
  230. });
  231. async function handleDetail(record: Recordable) {
  232. console.log('record', record);
  233. router.push({ path: `detail/${record.repairId || '20230215174919387'}` });
  234. }
  235. async function handleRecover(record: Recordable) {
  236. openModal(true, record);
  237. }
  238. function handleAdd(record: Recordable) {
  239. openAddModal(true, record);
  240. }
  241. function handleOut(record: Recordable) {
  242. openOutModal(true, record);
  243. }
  244. function handleOrder() {
  245. openModal(true);
  246. }
  247. function changeTable(val: string) {
  248. tableType.value = val;
  249. reload();
  250. }
  251. return {
  252. registerTable,
  253. reload,
  254. t,
  255. tableType,
  256. openAddModal,
  257. registerOut,
  258. registerAdd,
  259. changeTable,
  260. handleOrder,
  261. getCheckPerm,
  262. handleDetail,
  263. handleAdd,
  264. handleOut,
  265. handleRecover,
  266. registerRecovery,
  267. };
  268. },
  269. });
  270. </script>
  271. <style lang="less" scoped>
  272. .desc-wrap-BasicTable {
  273. background-color: #f0f2f5;
  274. .vben-basic-table-form-container {
  275. padding: 0;
  276. }
  277. }
  278. </style>