index.vue 14 KB

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