productArchive.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <div>
  3. <a-card :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px">
  4. <div class="table-page-search-wrapper">
  5. <a-form :model="queryParams" :label-col="labelCol" :wrapper-col="wrapperCol" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="8" :sm="8">
  8. <a-form-item label="分类(class)">
  9. <ApiSelect
  10. :api="classOption"
  11. showSearch
  12. v-model:value="queryParams.classId"
  13. :filterOption="true"
  14. resultField="records"
  15. labelField="name"
  16. valueField="id"
  17. :params="{ pageSize: -1 }"
  18. optionFilterProp="label"
  19. />
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="8" :sm="8">
  23. <a-form-item label="编码(code)">
  24. <j-input placeholder="请输入" v-model:value="queryParams.code" />
  25. </a-form-item>
  26. </a-col>
  27. <template v-if="toggleSearchStatus">
  28. <a-col :md="8" :sm="8">
  29. <a-form-item label="中文名(Chinese name)">
  30. <j-input placeholder="请输入" v-model:value="queryParams.chineseName" />
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="8" :sm="8">
  34. <a-form-item label="英文名(English name)">
  35. <j-input placeholder="请输入" v-model:value="queryParams.englishName" />
  36. </a-form-item>
  37. </a-col>
  38. <!-- <a-col :md="8" :sm="8">
  39. <a-form-item label="规格(specifications)">
  40. <a-input placeholder="请输入" v-model:value="queryParams.specifications"></a-input>
  41. </a-form-item>
  42. </a-col> -->
  43. <a-col :md="8" :sm="8">
  44. <a-form-item label="型号(model)">
  45. <JDictSelectTag v-model:value="queryParams.model" placeholder="请选择" dictCode="model_typer" showSearch/>
  46. </a-form-item>
  47. </a-col>
  48. <a-col :md="8" :sm="8">
  49. <a-form-item label="备件号(partno)">
  50. <j-input placeholder="请输入" v-model:value="queryParams.partno" />
  51. </a-form-item>
  52. </a-col>
  53. <a-col :md="8" :sm="8">
  54. <a-form-item label="中文别名(Chinese allas)">
  55. <j-input placeholder="请输入" v-model:value="queryParams.chineseAlias" />
  56. </a-form-item>
  57. </a-col>
  58. <a-col :md="8" :sm="8">
  59. <a-form-item label="英文别名(englidsh allas)" >
  60. <j-input placeholder="请输入" v-model:value="queryParams.englishAlias" />
  61. </a-form-item>
  62. </a-col>
  63. <a-col :md="8" :sm="8">
  64. <a-form-item label="状态(status)">
  65. <JDictSelectTag v-model:value="queryParams.status" placeholder="请选择" dictCode="valid_status" />
  66. </a-form-item>
  67. </a-col>
  68. <a-col :md="8" :sm="8">
  69. <a-form-item label="虚拟产品(virtual product)">
  70. <JDictSelectTag v-model:value="queryParams.virtualProduct" placeholder="请选择" dictCode="yes_or_no" />
  71. </a-form-item>
  72. </a-col>
  73. <a-col :md="8" :sm="8">
  74. <a-form-item label="有害物质(harmful substances)">
  75. <JDictSelectTag v-model:value="queryParams.harmfulSubstances" placeholder="请选择" dictCode="yes_or_no" />
  76. </a-form-item>
  77. </a-col>
  78. </template>
  79. <a-col :md="8" :sm="8">
  80. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  81. <a-button type="primary" @click="searchQuery">查询(search)</a-button>
  82. <a-button type="primary" @click="searchReset" style="margin-left: 8px">重置(reset)</a-button>
  83. <a @click="handleToggleSearch" style="margin-left: 8px">
  84. {{ toggleSearchStatus ? '收起' : '展开' }}
  85. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  86. </a>
  87. </span>
  88. </a-col>
  89. </a-row>
  90. </a-form>
  91. </div>
  92. </a-card>
  93. <a-card :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px">
  94. <!-- 操作按钮区域 -->
  95. <div style="margin-bottom: 4px">
  96. <a-button @click="handleAdd" type="primary" preIcon="ant-design:plus" style="margin-right: 1%" v-auth="'baseCode:base_product_archive:add'">新增(add)</a-button>
  97. <a-dropdown v-if="selectedRowKeys.length > 0">
  98. <template #overlay>
  99. <a-menu v-auth="'baseCode:base_product_archive:deleteBatch'">
  100. <a-menu-item key="1" @click="batchHandleDelete" >
  101. <Icon icon="ant-design:delete-outlined" />
  102. 删除
  103. </a-menu-item>
  104. </a-menu>
  105. </template>
  106. <a-button v-auth="'baseCode:base_product_archive:deleteBatch'"
  107. >批量操作
  108. <Icon icon="mdi:chevron-down" />
  109. </a-button>
  110. </a-dropdown>
  111. </div>
  112. <a-alert type="info" show-icon class="alert" style="margin-bottom: 8px">
  113. <template #message>
  114. <template v-if="selectedRowKeys.length > 0">
  115. <span>已选中 {{ selectedRowKeys.length }} 条记录</span>
  116. <a-divider type="vertical" />
  117. <a @click="selectedRowKeys = []">清空</a>
  118. </template>
  119. <template v-else>
  120. <span>未选中任何数据</span>
  121. </template>
  122. </template>
  123. </a-alert>
  124. <a-table
  125. :columns="columns"
  126. :row-key="(record) => record.id"
  127. :data-source="dataSource"
  128. bordered
  129. size="small"
  130. @change="handleTableChange"
  131. :pagination="pagination"
  132. :scroll="{ x: 3000 }"
  133. :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  134. >
  135. <template #bodyCell="{ column, record }">
  136. <template v-if="column.key === 'operation'">
  137. <span>
  138. <a @click="handleemit(record)" v-auth="'baseCode:base_product_archive:edit'">编辑(edit)</a>
  139. <a-divider type="vertical" />
  140. <a-popconfirm title="确定删除吗?" @confirm="() => deleteList(record)" v-auth="'baseCode:base_product_archive:delete'">
  141. <a v-auth="'baseCode:base_product_archive:delete'">删除(delete)</a>
  142. </a-popconfirm>
  143. </span>
  144. </template>
  145. </template>
  146. </a-table>
  147. </a-card>
  148. <productArchiveModel ref="productArchiveModelRef" @success="loadData" />
  149. </div>
  150. </template>
  151. <script lang="ts" setup>
  152. import { onMounted, ref } from 'vue';
  153. import { usePagination } from 'vue-request';
  154. import { defHttp } from '/@/utils/http/axios';
  155. import { message } from 'ant-design-vue';
  156. import { filterObj, getFileAccessHttpUrl } from '/@/utils/common/compUtils';
  157. import { JDictSelectTag, JInput ,ApiSelect} from '/@/components/Form';
  158. import JSelectInput from '/@/components/Form/src/jeecg/components/JSelectInput.vue';
  159. import productArchiveModel from './components/productArchiveModel.vue';
  160. const productArchiveModelRef = ref();
  161. const columns = [
  162. {
  163. title: '分类(class)',
  164. dataIndex: 'classId_dictText',
  165. key: 'classId',
  166. align: 'center',
  167. },
  168. {
  169. title: '编码(code)',
  170. dataIndex: 'code',
  171. key: 'code',
  172. align: 'center',
  173. },
  174. {
  175. title: '备件号(partno)',
  176. key: 'partno',
  177. dataIndex: 'partno',
  178. align: 'center',
  179. ellipsis:true,
  180. },
  181. {
  182. title: '英文名(English name)',
  183. key: 'englishName',
  184. dataIndex: 'englishName',
  185. width: 300,
  186. align: 'center',
  187. ellipsis:true,
  188. },
  189. {
  190. title: '型号(model)',
  191. key: 'model',
  192. dataIndex: 'model',
  193. align: 'center',
  194. },
  195. {
  196. title: '中文名(Chinese name)',
  197. dataIndex: 'chineseName',
  198. key: 'chineseName',
  199. align: 'center',
  200. width: 200,
  201. },
  202. {
  203. title: '计量单位(measurement unit)',
  204. key: 'measurementUnit',
  205. dataIndex: 'measurementUnit',
  206. align: 'center',
  207. width: 250,
  208. },
  209. {
  210. title: '税率(tax rate)',
  211. key: 'taxRate',
  212. dataIndex: 'taxRate',
  213. align: 'center',
  214. customRender: function (t, r, index) {
  215. if (t.text && t.text !== '') {
  216. return t.text + '%';
  217. } else {
  218. return '';
  219. }
  220. },
  221. },
  222. {
  223. title: '虚拟产品(virtual product)',
  224. key: 'virtualProduct',
  225. dataIndex: 'virtualProduct',
  226. align: 'center',
  227. customRender: function (t, r, index) {
  228. if (t.text == 1) {
  229. return '是(yes)';
  230. } else if (t.text == 0) {
  231. return '否(no)';
  232. } else {
  233. return '';
  234. }
  235. },
  236. },
  237. {
  238. title: '有害物质(harmful substances)',
  239. key: 'harmfulSubstances',
  240. dataIndex: 'harmfulSubstances',
  241. align: 'center',
  242. width: 250,
  243. customRender: function (t, r, index) {
  244. if (t.text == 1) {
  245. return '是(yes)';
  246. } else if (t.text == 0) {
  247. return '否(no)';
  248. } else {
  249. return '';
  250. }
  251. },
  252. },
  253. {
  254. title: '状态(status)',
  255. key: 'status',
  256. dataIndex: 'status',
  257. align: 'center',
  258. customRender: function (t, r, index) {
  259. if (t.text == 1) {
  260. return '启用(enable)';
  261. } else if (t.text == 0) {
  262. return '停用(disable)';
  263. } else {
  264. return '';
  265. }
  266. },
  267. },
  268. {
  269. title: '修改人',
  270. key: 'updateBy',
  271. dataIndex: 'updateBy',
  272. align: 'center',
  273. },
  274. {
  275. title: '修改时间',
  276. key: 'updateTime',
  277. dataIndex: 'updateTime',
  278. align: 'center',
  279. },
  280. {
  281. title: '操作(operation)',
  282. key: 'operation',
  283. dataIndex: 'operation',
  284. align: 'center',
  285. fixed: 'right',
  286. },
  287. ];
  288. const labelCol = ref({
  289. xs: { span: 24 },
  290. sm: { span: 9 },
  291. });
  292. const wrapperCol = ref({
  293. xs: { span: 24 },
  294. sm: { span: 15 },
  295. });
  296. const labelCol1 = ref({
  297. xs: { span: 24 },
  298. sm: { span: 12 },
  299. });
  300. const wrapperCol1 = ref({
  301. xs: { span: 24 },
  302. sm: { span: 12 },
  303. });
  304. const dataSource = ref([]);
  305. let selectedRowKeys = ref([]);
  306. const toggleSearchStatus = ref(false);
  307. const queryParams = ref({
  308. classId: '',
  309. code: '',
  310. chineseName: '',
  311. englishName: '',
  312. specifications: '',
  313. model: '',
  314. chineseAlias: '',
  315. englishAlias: '',
  316. status: '',
  317. virtualProduct: '',
  318. harmfulSubstances: '',
  319. partno:''
  320. });
  321. let pagination = ref({
  322. current: 1,
  323. pageSize: 10,
  324. total: '', // 假设总共有100条数据
  325. showSizeChanger: true,
  326. showQuickJumper: true,
  327. showTotal: (total, range) => {
  328. return range[0] + '-' + range[1] + ' 共' + total + '条';
  329. },
  330. size: 'small',
  331. });
  332. onMounted(() => {
  333. //初始加载页面
  334. loadData();
  335. // getOptiom();
  336. });
  337. function loadData() {
  338. let params = getQueryParams();
  339. defHttp
  340. .get({ url: '/baseCode/baseProductArchive/list', params }, { isTransformResponse: false })
  341. .then((res) => {
  342. if (res.success) {
  343. dataSource.value = res.result.records;
  344. pagination.value.total = res.result.total;
  345. pagination.value.current = res.result.current;
  346. pagination.value.pageSize = res.result.size;
  347. } else {
  348. message.error(res.message);
  349. }
  350. })
  351. .finally(() => {
  352. // loading.value = false;
  353. });
  354. }
  355. function getQueryParams() {
  356. let params = Object.assign(queryParams.value);
  357. params.pageNo = pagination.value.current;
  358. params.pageSize = pagination.value.pageSize;
  359. return filterObj(params);
  360. }
  361. function handleTableChange(paginations, filters, sorter) {
  362. pagination.value.total = paginations.total;
  363. pagination.value.current = paginations.current;
  364. pagination.value.pageSize = paginations.pageSize;
  365. loadData();
  366. }
  367. // function getOptiom() {
  368. // defHttp
  369. // .get({ url: 'baseCode/baseProductClass/list', params: {pageSize:-1} }, { isTransformResponse: false })
  370. // .then((res) => {
  371. // if (res.success) {
  372. // classOption.value = [];
  373. // res.result.records.forEach((element) => {
  374. // var obj = {
  375. // label: element.name ? element.name : '无名称请维护',
  376. // value: element.id ? element.id : '',
  377. // };
  378. // classOption.value.push(obj);
  379. // });
  380. // }
  381. // })
  382. // .finally(() => {
  383. // // loading.value = false;
  384. // });
  385. // }
  386. function searchQuery() {
  387. loadData();
  388. }
  389. function searchReset() {
  390. queryParams.value = {
  391. classId: '',
  392. code: '',
  393. chineseName: '',
  394. englishName: '',
  395. specifications: '',
  396. model: '',
  397. chineseAlias: '',
  398. englishAlias: '',
  399. status: '',
  400. virtualProduct: '',
  401. harmfulSubstances: '',
  402. partno:''
  403. };
  404. pagination.value.current = 1;
  405. pagination.value.pageSize = 10;
  406. loadData();
  407. }
  408. function handleToggleSearch() {
  409. toggleSearchStatus.value = !toggleSearchStatus.value;
  410. }
  411. function onSelectChange(keys) {
  412. selectedRowKeys.value = keys;
  413. }
  414. function handleAdd() {
  415. productArchiveModelRef.value.getForm('add');
  416. }
  417. function handleemit(record) {
  418. productArchiveModelRef.value.getForm('emidt', record);
  419. }
  420. function deleteList(record) {
  421. let params = { id: record.id };
  422. defHttp.delete({ url: '/baseCode/baseProductArchive/delete', params }, { joinParamsToUrl: true }).then((res) => {
  423. searchReset();
  424. });
  425. }
  426. function batchHandleDelete() {
  427. let params = { ids: selectedRowKeys.value.join(',') };
  428. defHttp.delete({ url: '/baseCode/baseProductArchive/deleteBatch', params }, { joinParamsToUrl: true }).then((res) => {
  429. searchReset();
  430. });
  431. }
  432. function classOption(){
  433. var params = {pageSize:-1}
  434. return defHttp.get({ url: 'baseCode/baseProductClass/list',params})
  435. }
  436. </script>
  437. <style scoped lang="less">
  438. /deep/.ant-form-item {
  439. margin-bottom: 8px !important;
  440. }
  441. // /deep/.ant-table-wrapper .ant-table-thead > tr > th, .ant-table-wrapper .ant-table-thead > tr > td{
  442. // padding: 8px !important;
  443. // }
  444. </style>