index.vue 8.9 KB

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