index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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. ifShow: getCheckPerm('device-priority'),
  17. onClick: handlePriority.bind(null, record),
  18. },
  19. {
  20. label: '出库',
  21. ifShow: getCheckPerm('device-out'),
  22. onClick: handleCheckout.bind(null, record),
  23. },
  24. {
  25. label: '编辑',
  26. //ifShow: getCheckPerm('device-update') && Boolean(record.outType),
  27. onClick: handleEdit.bind(null, record),
  28. },
  29. {
  30. label: '解绑',
  31. ifShow: getCheckPerm('device-unbind') && Boolean(record.userName),
  32. color: 'error',
  33. onClick: handleUnbind.bind(null, record),
  34. },
  35. {
  36. label: '删除',
  37. color: 'error',
  38. ifShow: getCheckPerm('device-delete'), // && !(Boolean(record.outType) || Boolean(record.userName)),
  39. onClick: handleDelete.bind(null, record),
  40. },
  41. ]"
  42. />
  43. </template>
  44. </BasicTable>
  45. </div>
  46. <batchOutflowModal @register="registerLinkModal" @reload="reload" />
  47. <detailModal @register="register" @reload="reload" />
  48. <batchPutModal @register="registerPut" @reload="reload" />
  49. <PutModal @register="registerEnter" @reload="reload" />
  50. <editModal @register="registerEditModal" @reload="reload" />
  51. <priorityMoadl @update="reload" @register="registerPriority" />
  52. </PageWrapper>
  53. </template>
  54. <script lang="ts">
  55. import { defineComponent, h, onMounted } from 'vue';
  56. import {
  57. BasicTable,
  58. useTable,
  59. TableAction,
  60. BasicColumn,
  61. TableImg,
  62. FormProps,
  63. } from '/@/components/Table';
  64. import { PageWrapper } from '/@/components/Page';
  65. import { Descriptions } from 'ant-design-vue';
  66. import { useI18n } from '/@/hooks/web/useI18n';
  67. import { useMessage } from '/@/hooks/web/useMessage';
  68. import priorityMoadl from '../productOperation/modal/priorityMoadl.vue';
  69. import { cameraList } from '/@/api/customer';
  70. import { cameraDelete } from '/@/api/device'
  71. import batchOutflowModal from './OutflowModal.vue';
  72. import detailModal from './detailsMoadl.vue';
  73. import batchPutModal from './batchPutModal.vue';
  74. import PutModal from './putModal.vue';
  75. import editModal from './editModal.vue';
  76. import { useModal } from '/@/components/Modal';
  77. import { useRouter } from 'vue-router';
  78. import { UnbindCameraApi, cameraAllType } from '/@/api/account';
  79. import { usePermissionStore } from '/@/store/modules/permission';
  80. import { lte } from 'lodash';
  81. export default defineComponent({
  82. components: {
  83. BasicTable,
  84. TableAction,
  85. PageWrapper,
  86. TableImg,
  87. priorityMoadl,
  88. editModal,
  89. batchOutflowModal,
  90. detailModal,
  91. batchPutModal,
  92. PutModal,
  93. [Descriptions.name]: Descriptions,
  94. [Descriptions.Item.name]: Descriptions.Item,
  95. },
  96. setup() {
  97. const { t } = useI18n();
  98. const { createMessage, createConfirm } = useMessage();
  99. const permissionStore = usePermissionStore();
  100. const { getCheckPerm } = permissionStore;
  101. const [registerPriority, { openModal: openPriorityModal }] = useModal();
  102. const [registerLinkModal, { openModal: openLinkModal }] = useModal();
  103. const [registerEditModal, { openModal: openEditModal }] = useModal();
  104. const [register, { openModal }] = useModal();
  105. const [registerPut, { openModal: openModalPut }] = useModal();
  106. const [registerEnter, { openModal: openModalEnter }] = useModal();
  107. const router = useRouter();
  108. let companyId: Number = 0;
  109. try {
  110. companyId = Number(router.currentRoute.value.params.id) - 0;
  111. } catch (error) {
  112. }
  113. onMounted(() => {
  114. // console.log(router.currentRoute.value.params.id);
  115. });
  116. const columns: BasicColumn[] = [
  117. {
  118. title: 'SN码',
  119. dataIndex: 'snCode',
  120. width: 180,
  121. },
  122. {
  123. title: 'wifi名称',
  124. dataIndex: 'wifiName',
  125. width: 150,
  126. },
  127. {
  128. title: '设备类型',
  129. dataIndex: 'typeStr',
  130. ellipsis: false,
  131. width: 100,
  132. // customRender: ({ record }) => {
  133. // let typeObj ={
  134. // '0':'旧双目相机',
  135. // '1':'四维看看',
  136. // '2':'四维看看lite',
  137. // '3':'四维看看',
  138. // '9':'四维看见',
  139. // '10':'四维深时',
  140. // '11':'四维深光',
  141. // }
  142. // return typeObj[record.type]
  143. // }
  144. },
  145. {
  146. title: '激活时间',
  147. dataIndex: 'activatedTime',
  148. width: 180,
  149. },
  150. {
  151. title: '出库类型',
  152. dataIndex: 'outType',
  153. width: 80,
  154. customRender: ({ record }) => {
  155. let typeObj ={
  156. '0':t('routes.product.outType.0'),
  157. '4':t('routes.product.outType.4'),
  158. '1':t('routes.product.outType.1'),
  159. '2':t('routes.product.outType.2'),
  160. '3':t('routes.product.outType.3'),
  161. }
  162. return typeObj[record.outType] || '未出库'
  163. }
  164. },
  165. {
  166. title: '经销商名称',
  167. dataIndex: 'agentName',
  168. ellipsis: false,
  169. width: 100,
  170. },
  171. {
  172. title: '客户名称',
  173. dataIndex: 'companyName',
  174. width: 80,
  175. },
  176. {
  177. title: '购买日期',
  178. dataIndex: 'buyDate',
  179. width: 100,
  180. },
  181. {
  182. title: '保修届满日期',
  183. dataIndex: 'warrantyDate',
  184. width: 100,
  185. },
  186. {
  187. title: '绑定账号',
  188. dataIndex: 'userName',
  189. width: 180,
  190. customRender({ record }) {
  191. return record.userName?record.userName:'未绑定'
  192. },
  193. },
  194. {
  195. title: '操作',
  196. dataIndex: 'action',
  197. slots: { customRender: 'action' },
  198. ifShow: true,
  199. fixed: 'right',
  200. flag: 'ACTION',
  201. width: 240,
  202. },
  203. ];
  204. const searchForm: Partial<FormProps> = {
  205. labelWidth: 100,
  206. // showAdvancedButton: true,
  207. autoAdvancedLine:1,
  208. actionColOptions: {
  209. span: 24,
  210. },
  211. // compact: true,
  212. schemas: [
  213. {
  214. field: 'snCode',
  215. component: 'Input',
  216. label: 'SN码',
  217. colProps: {
  218. xl: 6,
  219. xxl: 6,
  220. },
  221. },{
  222. field: 'type',
  223. component: 'ApiSelect',
  224. label: '设备类型',
  225. colProps: {
  226. xl: 6,
  227. xxl: 6,
  228. },
  229. componentProps: {
  230. api: cameraAllType,
  231. numberToString: true,
  232. labelField: 'name',
  233. valueField: 'cameraType',
  234. immediate: true,
  235. // options: [
  236. // {
  237. // label: t('routes.product.type.0'),
  238. // value: 0,
  239. // key: '0',
  240. // },{
  241. // label: t('routes.product.type.1'),
  242. // value: 1,
  243. // key: '1',
  244. // },{
  245. // label: t('routes.product.type.2'),
  246. // value: 9,
  247. // key: '9',
  248. // },{
  249. // label: t('routes.product.type.3'),
  250. // value: 10,
  251. // key: '10',
  252. // },{
  253. // label: t('routes.product.type.11'),
  254. // value: 11,
  255. // key: '11',
  256. // },
  257. // ],
  258. },
  259. },
  260. {
  261. field: 'ctivated',
  262. label: '激活时间',
  263. component: 'RangePicker',
  264. componentProps: {
  265. format: 'YYYY-MM-DD',
  266. valueFormat:'YYYY-MM-DD',
  267. },
  268. colProps: {
  269. xl: 7,
  270. xxl: 7,
  271. },
  272. },
  273. {
  274. field: 'outType',
  275. component: 'Select',
  276. label: '出库类型',
  277. colProps: {
  278. xl: 6,
  279. xxl: 6,
  280. },
  281. componentProps: {
  282. options: [
  283. {
  284. label: t('routes.product.outType.0'),
  285. value: 0,
  286. key: '0',
  287. },{
  288. label: t('routes.product.outType.1'),
  289. value: 1,
  290. key: '1',
  291. },{
  292. label: t('routes.product.outType.2'),
  293. value: 2,
  294. key: '2',
  295. },{
  296. label: t('routes.product.outType.3'),
  297. value: 3,
  298. key: '3',
  299. },
  300. ],
  301. },
  302. },
  303. {
  304. field: 'companyName',
  305. label: '客户名称',
  306. component: 'Input',
  307. colProps: {
  308. xl: 6,
  309. xxl: 6,
  310. },
  311. componentProps: {
  312. // api: brandTypeListApi,
  313. resultField: 'list',
  314. labelField: 'name',
  315. valueField: 'brandType',
  316. params: {
  317. page: 1,
  318. limit: 1000,
  319. },
  320. },
  321. },
  322. {
  323. field: 'agentName',
  324. component: 'Input',
  325. label: '经销商名称',
  326. colProps: {
  327. xl: 7,
  328. xxl: 7,
  329. },
  330. },
  331. {
  332. field: 'bindStatus',
  333. component: 'Select',
  334. label: '绑定状态',
  335. colProps: {
  336. xl: 6,
  337. xxl: 6,
  338. },
  339. componentProps: {
  340. options: [
  341. {
  342. label: '未绑定',
  343. value: 0,
  344. key: '0',
  345. },{
  346. label: '已绑定',
  347. value: 1,
  348. key: '1',
  349. }
  350. ],
  351. },
  352. },
  353. {
  354. field: 'userName',
  355. component: 'Input',
  356. label: '绑定账号',
  357. colProps: {
  358. xl: 6,
  359. xxl: 6,
  360. },
  361. },
  362. ],
  363. };
  364. const [registerTable, { reload }] = useTable({
  365. api: cameraList,
  366. // title: '四维深时场景列表',
  367. // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
  368. columns: columns,
  369. // rowSelection: { type: 'checkbox',onChange: onSelectChange },
  370. searchInfo: { companyId },
  371. useSearchForm: true,
  372. formConfig: searchForm,
  373. showTableSetting: true,
  374. showIndexColumn:false,
  375. rowKey: 'id',
  376. beforeFetch:(T)=>{
  377. if(T.ctivated){
  378. T.activatedStartTime = T.ctivated[0]
  379. T.activatedEndTime = T.ctivated[1]
  380. }
  381. return T
  382. },
  383. fetchSetting: {
  384. pageField: 'pageNum',
  385. sizeField: 'pageSize',
  386. listField: 'list',
  387. totalField: 'total',
  388. },
  389. canResize: false,
  390. });
  391. async function handleUnbind(record: Recordable) {
  392. createConfirm({
  393. iconType: 'warning',
  394. title: () => h('span', '温馨提示'),
  395. content: '解绑后用户将看不到该相机拍摄的场景。<br/>确定解绑吗?',
  396. onOk: async () => {
  397. await UnbindCameraApi({cameraId:record.id})
  398. createMessage.success(t('common.optSuccess'));
  399. reload()
  400. },
  401. });
  402. }
  403. async function handleDelete(record: Recordable){
  404. createConfirm({
  405. iconType: 'warning',
  406. title: () => h('span', '温馨提示'),
  407. content: '删除设备后需要重新入库<br/>确定删除吗?',
  408. onOk: async () => {
  409. await cameraDelete({id:record.id})
  410. createMessage.success(t('common.optSuccess'));
  411. reload()
  412. },
  413. });
  414. }
  415. function handlePriority(record) {
  416. openPriorityModal(true, {cameraId:record.id});
  417. }
  418. function deviceLink() {
  419. openLinkModal(true);
  420. }
  421. function handleCheckout(record: Recordable) {
  422. openModal(true, {
  423. ...record,
  424. isUpdate: false,
  425. });
  426. }
  427. function handleEdit(record: Recordable) {
  428. openEditModal(true, {
  429. ...record,
  430. isUpdate: true,
  431. });
  432. }
  433. function put() {
  434. openModalEnter(true)
  435. }
  436. function batchPut() {
  437. console.log('批量入库');
  438. openModalPut(true, {})
  439. }
  440. function batchOutflow() {
  441. console.log('批量出库');
  442. openLinkModal(true, {})
  443. }
  444. return {
  445. registerTable,
  446. handleUnbind,
  447. deviceLink,
  448. registerLinkModal,
  449. register,
  450. registerEnter,
  451. put,
  452. batchPut,
  453. batchOutflow,
  454. handleEdit,
  455. handleCheckout,
  456. registerEditModal,
  457. reload,
  458. handleDelete,
  459. registerPut,
  460. getCheckPerm,
  461. handlePriority,
  462. registerPriority,
  463. };
  464. },
  465. });
  466. </script>
  467. <style lang="less" scoped>
  468. .desc-wrap-BasicTable {
  469. background-color: #f0f2f5;
  470. .vben-basic-table-form-container {
  471. padding: 0;
  472. }
  473. }
  474. </style>