index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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') && !(Boolean(record.outType) || Boolean(record.userName)),
  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. }
  119. return typeObj[record.type]
  120. }
  121. },
  122. {
  123. title: '激活时间',
  124. dataIndex: 'activatedTime',
  125. width: 180,
  126. },
  127. {
  128. title: '出库类型',
  129. dataIndex: 'outType',
  130. width: 80,
  131. customRender: ({ record }) => {
  132. let typeObj ={
  133. '0':t('routes.product.outType.0'),
  134. '4':t('routes.product.outType.4'),
  135. '1':t('routes.product.outType.1'),
  136. '2':t('routes.product.outType.2'),
  137. '3':t('routes.product.outType.3'),
  138. }
  139. return typeObj[record.outType] || '未出库'
  140. }
  141. },
  142. {
  143. title: '经销商名称',
  144. dataIndex: 'agentName',
  145. ellipsis: false,
  146. width: 100,
  147. },
  148. {
  149. title: '客户名称',
  150. dataIndex: 'companyName',
  151. width: 80,
  152. },
  153. {
  154. title: '绑定账号',
  155. dataIndex: 'userName',
  156. width: 180,
  157. customRender({ record }) {
  158. return record.userName?record.userName:'未绑定'
  159. },
  160. },
  161. {
  162. title: '操作',
  163. dataIndex: 'action',
  164. slots: { customRender: 'action' },
  165. ifShow: true,
  166. fixed: 'right',
  167. flag: 'ACTION',
  168. width: 120,
  169. },
  170. ];
  171. const searchForm: Partial<FormProps> = {
  172. labelWidth: 100,
  173. // showAdvancedButton: true,
  174. autoAdvancedLine:1,
  175. actionColOptions: {
  176. span: 24,
  177. },
  178. // compact: true,
  179. schemas: [
  180. {
  181. field: 'snCode',
  182. component: 'Input',
  183. label: 'SN码',
  184. colProps: {
  185. xl: 6,
  186. xxl: 6,
  187. },
  188. },{
  189. field: 'type',
  190. component: 'Select',
  191. label: '设备类型',
  192. colProps: {
  193. xl: 6,
  194. xxl: 6,
  195. },
  196. componentProps: {
  197. options: [
  198. {
  199. label: t('routes.product.type.0'),
  200. value: 0,
  201. key: '0',
  202. },{
  203. label: t('routes.product.type.1'),
  204. value: 1,
  205. key: '1',
  206. },{
  207. label: t('routes.product.type.2'),
  208. value: 9,
  209. key: '9',
  210. },{
  211. label: t('routes.product.type.3'),
  212. value: 10,
  213. key: '10',
  214. },
  215. ],
  216. },
  217. },
  218. {
  219. field: 'ctivated',
  220. label: '激活时间',
  221. component: 'RangePicker',
  222. componentProps: {
  223. format: 'YYYY-MM-DD',
  224. valueFormat:'YYYY-MM-DD',
  225. },
  226. colProps: {
  227. xl: 7,
  228. xxl: 7,
  229. },
  230. },
  231. {
  232. field: 'outType',
  233. component: 'Select',
  234. label: '出库类型',
  235. colProps: {
  236. xl: 6,
  237. xxl: 6,
  238. },
  239. componentProps: {
  240. options: [
  241. {
  242. label: t('routes.product.outType.0'),
  243. value: 0,
  244. key: '0',
  245. },{
  246. label: t('routes.product.outType.4'),
  247. value: 4,
  248. key: '4',
  249. },{
  250. label: t('routes.product.outType.1'),
  251. value: 1,
  252. key: '1',
  253. },{
  254. label: t('routes.product.outType.2'),
  255. value: 2,
  256. key: '2',
  257. },{
  258. label: t('routes.product.outType.3'),
  259. value: 3,
  260. key: '3',
  261. },
  262. ],
  263. },
  264. },
  265. {
  266. field: 'companyName',
  267. label: '客户名称',
  268. component: 'Input',
  269. colProps: {
  270. xl: 6,
  271. xxl: 6,
  272. },
  273. componentProps: {
  274. // api: brandTypeListApi,
  275. resultField: 'list',
  276. labelField: 'name',
  277. valueField: 'brandType',
  278. params: {
  279. page: 1,
  280. limit: 1000,
  281. },
  282. },
  283. },
  284. {
  285. field: 'agentName',
  286. component: 'Input',
  287. label: '经销商名称',
  288. colProps: {
  289. xl: 7,
  290. xxl: 7,
  291. },
  292. },
  293. {
  294. field: 'userName',
  295. component: 'Input',
  296. label: '绑定账号',
  297. colProps: {
  298. xl: 6,
  299. xxl: 6,
  300. },
  301. },
  302. ],
  303. };
  304. const [registerTable, { reload }] = useTable({
  305. api: cameraList,
  306. // title: '四维深时场景列表',
  307. // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
  308. columns: columns,
  309. // rowSelection: { type: 'checkbox',onChange: onSelectChange },
  310. searchInfo: { companyId },
  311. useSearchForm: true,
  312. formConfig: searchForm,
  313. showTableSetting: true,
  314. showIndexColumn:false,
  315. rowKey: 'id',
  316. beforeFetch:(T)=>{
  317. if(T.ctivated){
  318. T.activatedStartTime = T.ctivated[0]
  319. T.activatedEndTime = T.ctivated[1]
  320. }
  321. return T
  322. },
  323. fetchSetting: {
  324. pageField: 'pageNum',
  325. sizeField: 'pageSize',
  326. listField: 'list',
  327. totalField: 'total',
  328. },
  329. canResize: false,
  330. });
  331. async function handleUnbind(record: Recordable) {
  332. createConfirm({
  333. iconType: 'warning',
  334. title: () => h('span', '温馨提示'),
  335. content: '解绑后用户将看不到该相机拍摄的场景。<br/>确定解绑吗?',
  336. onOk: async () => {
  337. await UnbindCameraApi({cameraId:record.id})
  338. createMessage.success(t('common.optSuccess'));
  339. reload()
  340. },
  341. });
  342. }
  343. async function handleDelete(record: Recordable){
  344. createConfirm({
  345. iconType: 'warning',
  346. title: () => h('span', '温馨提示'),
  347. content: '删除设备后需要重新入库<br/>确定删除吗?',
  348. onOk: async () => {
  349. await cameraDelete({id:record.id})
  350. createMessage.success(t('common.optSuccess'));
  351. reload()
  352. },
  353. });
  354. }
  355. function deviceLink() {
  356. openLinkModal(true);
  357. }
  358. function handleCheckout(record: Recordable) {
  359. openModal(true, {
  360. ...record,
  361. isUpdate: false,
  362. });
  363. }
  364. function handleEdit(record: Recordable) {
  365. openModal(true, {
  366. ...record,
  367. isUpdate: true,
  368. });
  369. }
  370. function put() {
  371. openModalEnter(true)
  372. }
  373. function batchPut() {
  374. console.log('批量入库');
  375. openModalPut(true, {})
  376. }
  377. function batchOutflow() {
  378. console.log('批量出库');
  379. openLinkModal(true, {})
  380. }
  381. return {
  382. registerTable,
  383. handleUnbind,
  384. deviceLink,
  385. registerLinkModal,
  386. register,
  387. registerEnter,
  388. put,
  389. batchPut,
  390. batchOutflow,
  391. handleEdit,
  392. handleCheckout,
  393. reload,
  394. handleDelete,
  395. registerPut,
  396. getCheckPerm,
  397. };
  398. },
  399. });
  400. </script>
  401. <style lang="less" scoped>
  402. .desc-wrap-BasicTable {
  403. background-color: #f0f2f5;
  404. .vben-basic-table-form-container {
  405. padding: 0;
  406. }
  407. }
  408. </style>