index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <PageWrapper contentBackground>
  3. <div class="desc-wrap-BasicTable">
  4. <BasicTable @register="registerTable">
  5. <template #toolbar>
  6. <a-button type="primary" @click="put" v-if="getCheckPerm('device-in')"> 入库</a-button>
  7. <a-button type="primary" @click="batchPut" v-if="getCheckPerm('device-all-in')"> 批量入库</a-button>
  8. <a-button type="primary" @click="batchOutflow" v-if="getCheckPerm('device-all-out')">批量出库</a-button>
  9. </template>
  10. <template #action="{ record }">
  11. <TableAction
  12. stopButtonPropagation
  13. :actions="[
  14. {
  15. label: '删除',
  16. color: 'error',
  17. ifShow: getCheckPerm('device-delete'),
  18. onClick: handleDelete.bind(null, record),
  19. },{
  20. label: '出库',
  21. ifShow: getCheckPerm('device-out') && !Boolean(record.outType),
  22. onClick: handleCheckout.bind(null, record),
  23. },{
  24. label: '编辑',
  25. ifShow: getCheckPerm('device-update') && Boolean(record.outType),
  26. onClick: handleEdit.bind(null, record),
  27. },{
  28. label: '解绑',
  29. ifShow: getCheckPerm('device-unbind') && Boolean(record.userName),
  30. color: 'error',
  31. onClick: handleUnbind.bind(null, record),
  32. },
  33. ]"
  34. />
  35. </template>
  36. </BasicTable>
  37. </div>
  38. <batchOutflowModal @register="registerLinkModal" @reload="reload" />
  39. <detailModal @register="register" @reload="reload" />
  40. <batchPutModal @register="registerPut" @reload="reload" />
  41. <PutModal @register="registerEnter" @reload="reload" />
  42. </PageWrapper>
  43. </template>
  44. <script lang="ts">
  45. import { defineComponent, h, onMounted } from 'vue';
  46. import {
  47. BasicTable,
  48. useTable,
  49. TableAction,
  50. BasicColumn,
  51. TableImg,
  52. FormProps,
  53. } from '/@/components/Table';
  54. import { PageWrapper } from '/@/components/Page';
  55. import { Descriptions } from 'ant-design-vue';
  56. import { useI18n } from '/@/hooks/web/useI18n';
  57. import { useMessage } from '/@/hooks/web/useMessage';
  58. import { cameraList } from '/@/api/customer';
  59. import { cameraDelete } from '/@/api/device'
  60. import batchOutflowModal from './OutflowModal.vue';
  61. import detailModal from './detailsMoadl.vue';
  62. import batchPutModal from './batchPutModal.vue';
  63. import { SCENE_TYPE } from '/@/settings/siteSetting';
  64. import PutModal from './putModal.vue';
  65. import { useModal } from '/@/components/Modal';
  66. import { useRouter } from 'vue-router';
  67. import { UnbindCameraApi } from '/@/api/account';
  68. import { usePermissionStore } from '/@/store/modules/permission';
  69. export default defineComponent({
  70. components: {
  71. BasicTable,
  72. TableAction,
  73. PageWrapper,
  74. TableImg,
  75. batchOutflowModal,
  76. detailModal,
  77. batchPutModal,
  78. PutModal,
  79. [Descriptions.name]: Descriptions,
  80. [Descriptions.Item.name]: Descriptions.Item,
  81. },
  82. setup() {
  83. const { t } = useI18n();
  84. const { createMessage, createConfirm } = useMessage();
  85. const permissionStore = usePermissionStore();
  86. const { getCheckPerm } = permissionStore;
  87. const [registerLinkModal, { openModal: openLinkModal }] = useModal();
  88. const [register, { openModal }] = useModal();
  89. const [registerPut, { openModal:openModalPut }] = useModal();
  90. const [registerEnter, { openModal:openModalEnter }] = useModal();
  91. const router = useRouter();
  92. const companyId: Number = router.currentRoute.value.params.id - 0;
  93. onMounted(() => {
  94. // console.log(router.currentRoute.value.params.id);
  95. });
  96. const columns: BasicColumn[] = [
  97. {
  98. title: 'SN码',
  99. dataIndex: 'snCode',
  100. width: 180,
  101. },
  102. {
  103. title: 'wifi名称',
  104. dataIndex: 'wifiName',
  105. width: 150,
  106. },
  107. {
  108. title: '设备类型',
  109. dataIndex: 'type',
  110. ellipsis: false,
  111. width: 80,
  112. customRender: ({ record }) => {
  113. let typeObj = {
  114. '0': '旧双目相机',
  115. '1': SCENE_TYPE[1],
  116. '2': SCENE_TYPE[1],
  117. '9': SCENE_TYPE[0],
  118. '10': SCENE_TYPE[2],
  119. '11': SCENE_TYPE[3],
  120. };
  121. return typeObj[record.type];
  122. }
  123. },
  124. {
  125. title: '激活时间',
  126. dataIndex: 'activatedTime',
  127. width: 180,
  128. },
  129. // {
  130. // title: '出库类型',
  131. // dataIndex: 'outType',
  132. // width: 80,
  133. // customRender: ({ record }) => {
  134. // let typeObj ={
  135. // '0':t('routes.product.outType.0'),
  136. // '4':t('routes.product.outType.4'),
  137. // '1':t('routes.product.outType.1'),
  138. // '2':t('routes.product.outType.2'),
  139. // '3':t('routes.product.outType.3'),
  140. // }
  141. // return typeObj[record.outType] || '未出库'
  142. // }
  143. // },
  144. // {
  145. // title: '经销商名称',
  146. // dataIndex: 'agentName',
  147. // ellipsis: false,
  148. // width: 100,
  149. // },
  150. // {
  151. // title: '客户名称',
  152. // dataIndex: 'companyName',
  153. // width: 80,
  154. // },
  155. // {
  156. // title: '绑定账号',
  157. // dataIndex: 'userName',
  158. // width: 180,
  159. // customRender({ record }) {
  160. // return record.userName?record.userName:'未绑定'
  161. // },
  162. // },
  163. {
  164. title: '操作',
  165. dataIndex: 'action',
  166. slots: { customRender: 'action' },
  167. ifShow: true,
  168. fixed: 'right',
  169. flag: 'ACTION',
  170. width: 120,
  171. },
  172. ];
  173. const searchForm: Partial<FormProps> = {
  174. labelWidth: 100,
  175. // showAdvancedButton: true,
  176. // compact: true,
  177. schemas: [
  178. {
  179. field: 'snCode',
  180. component: 'Input',
  181. label: 'SN码',
  182. colProps: {
  183. xl: 6,
  184. xxl: 6,
  185. },
  186. }
  187. ],
  188. };
  189. const [registerTable, { reload }] = useTable({
  190. api: cameraList,
  191. // title: '四维深时场景列表',
  192. // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
  193. columns: columns,
  194. // rowSelection: { type: 'checkbox',onChange: onSelectChange },
  195. searchInfo: { companyId },
  196. useSearchForm: true,
  197. formConfig: searchForm,
  198. showTableSetting: true,
  199. showIndexColumn:false,
  200. rowKey: 'id',
  201. beforeFetch:(T)=>{
  202. if(T.ctivated){
  203. T.activatedStartTime = T.ctivated[0]
  204. T.activatedEndTime = T.ctivated[1]
  205. }
  206. return T
  207. },
  208. fetchSetting: {
  209. pageField: 'pageNum',
  210. sizeField: 'pageSize',
  211. listField: 'list',
  212. totalField: 'total',
  213. },
  214. canResize: false,
  215. });
  216. async function handleUnbind(record: Recordable) {
  217. createConfirm({
  218. iconType: 'warning',
  219. title: () => h('span', '温馨提示'),
  220. content: '解绑后用户将看不到该相机拍摄的场景。<br/>确定解绑吗?',
  221. onOk: async () => {
  222. await UnbindCameraApi({cameraId:record.id})
  223. createMessage.success(t('common.optSuccess'));
  224. reload()
  225. },
  226. });
  227. }
  228. async function handleDelete(record: Recordable){
  229. createConfirm({
  230. iconType: 'warning',
  231. title: () => h('span', '温馨提示'),
  232. content: '删除设备后需要重新入库<br/>确定删除吗?',
  233. onOk: async () => {
  234. await cameraDelete({id:record.id})
  235. createMessage.success(t('common.optSuccess'));
  236. reload()
  237. },
  238. });
  239. }
  240. function deviceLink() {
  241. openLinkModal(true);
  242. }
  243. function handleCheckout(record: Recordable) {
  244. openModal(true, {
  245. ...record,
  246. isUpdate: false,
  247. });
  248. }
  249. function handleEdit(record: Recordable) {
  250. openModal(true, {
  251. ...record,
  252. isUpdate: true,
  253. });
  254. }
  255. function put() {
  256. openModalEnter(true)
  257. }
  258. function batchPut() {
  259. console.log('批量入库');
  260. openModalPut(true, {})
  261. }
  262. function batchOutflow() {
  263. console.log('批量出库');
  264. openLinkModal(true, {})
  265. }
  266. return {
  267. registerTable,
  268. handleUnbind,
  269. deviceLink,
  270. registerLinkModal,
  271. register,
  272. registerEnter,
  273. put,
  274. batchPut,
  275. batchOutflow,
  276. handleEdit,
  277. handleCheckout,
  278. reload,
  279. handleDelete,
  280. registerPut,
  281. getCheckPerm,
  282. };
  283. },
  284. });
  285. </script>
  286. <style lang="less" scoped>
  287. .desc-wrap-BasicTable {
  288. background-color: #f0f2f5;
  289. .vben-basic-table-form-container {
  290. padding: 0;
  291. }
  292. }
  293. </style>