index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <el-card class="content-z">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-form-item>
  7. <j-dict-select-tag
  8. v-model="queryParam.toolType"
  9. style="width: 150px"
  10. placeholder="选择工具名称"
  11. dict-code="tool_type"
  12. />
  13. </a-form-item>
  14. <a-form-item>
  15. <a-tree-select
  16. v-model="queryParam.deptId"
  17. style="width: 150px"
  18. :show-search="true"
  19. allow-clear
  20. placeholder="选择车间"
  21. :tree-data="treeData"
  22. tree-node-filter-prop="label"
  23. :replace-fields="{children:'children', title:'label', key:'id', value: 'id' }"
  24. />
  25. </a-form-item>
  26. <a-form-item>
  27. <a-input
  28. v-model="queryParam.storePlace"
  29. style="width: 150px"
  30. placeholder="选择存放处"
  31. />
  32. </a-form-item>
  33. <a-form-item>
  34. <a-select v-model="queryParam.testResult" placeholder="选择实验结果" style="width:150px">
  35. <a-select-option value="">
  36. 请选择
  37. </a-select-option>
  38. <a-select-option value="0">
  39. 不合格
  40. </a-select-option>
  41. <a-select-option value="1">
  42. 合格
  43. </a-select-option>
  44. </a-select>
  45. </a-form-item>
  46. <a-form-item>
  47. <a-input
  48. v-model="queryParam.toolCode"
  49. style="width: 150px"
  50. placeholder="输入编号"
  51. />
  52. </a-form-item>
  53. <a-form-item>
  54. <a-button type="primary" @click="searchQuery">查询</a-button>
  55. <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
  56. </a-form-item>
  57. </a-form>
  58. </div>
  59. <!-- 操作按钮区域 -->
  60. <div class="table-operator" style="margin: 15px 0">
  61. <a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
  62. <a-button ghost type="danger" @click="handleExportXls()">导出数据(含报废)</a-button>
  63. <a-dropdown type="danger">
  64. <a-menu slot="overlay">
  65. <a-menu-item key="0" @click="handleExportCode()">
  66. 导出选中
  67. </a-menu-item>
  68. <a-menu-item key="1" @click="handleExportCodeAll()">
  69. 导出全部
  70. </a-menu-item>
  71. </a-menu>
  72. <a-button style="margin-left: 8px">
  73. 批量导出二维码
  74. <a-icon type="down" />
  75. </a-button>
  76. </a-dropdown>
  77. <a-dropdown v-if="selectedRowKeys.length > 0">
  78. <a-menu slot="overlay">
  79. <a-menu-item key="1" @click="batchDel">
  80. <a-icon type="delete" />
  81. 删除
  82. </a-menu-item>
  83. </a-menu>
  84. <a-button style="margin-left: 8px">
  85. 批量操作
  86. <a-icon type="down" />
  87. </a-button>
  88. </a-dropdown>
  89. </div>
  90. <!-- table区域-begin -->
  91. <div>
  92. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  93. <i class="anticon anticon-info-circle ant-alert-icon" /> 已选择&nbsp;<a style="font-weight: 600">{{
  94. selectedRowKeys.length }}</a>项&nbsp;&nbsp;
  95. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  96. </div>
  97. <a-table
  98. ref="table"
  99. size="middle"
  100. bordered
  101. row-key="toolId"
  102. :columns="columns"
  103. :data-source="dataSource"
  104. :pagination="ipagination"
  105. :loading="loading"
  106. :row-selection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  107. @change="handleTableChange"
  108. >
  109. <span slot="action" slot-scope="text, record">
  110. <a-button size="small" type="primary" @click="perview(record)">
  111. 二维码
  112. </a-button>
  113. <a-divider type="vertical" />
  114. <a-button size="small" type="primary" @click="handleEdit(record)">
  115. 编辑
  116. </a-button>
  117. <a-divider type="vertical" />
  118. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.toolId)">
  119. <a-button size="small" type="danger">
  120. 删除
  121. </a-button>
  122. </a-popconfirm>
  123. </span>
  124. </a-table>
  125. <check-and-edit-model ref="modalForm" @ok="modalFormOk" />
  126. <a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
  127. <img alt="example" style="width: 100%" :src="previewImage">
  128. </a-modal>
  129. </div>
  130. <!-- table区域-end -->
  131. <!-- 表单区域 -->
  132. </el-card>
  133. </template>
  134. <script>
  135. import { listMixin } from '@/mixin/listMixin'
  136. import columns from './indexColumns'
  137. import CheckAndEditModel from './CheckAndEditModel'
  138. import { getAction, downFile } from '@/api/request'
  139. export default {
  140. components: {
  141. CheckAndEditModel
  142. },
  143. mixins: [listMixin],
  144. data() {
  145. return {
  146. // 查询条件
  147. previewVisible: false,
  148. previewImage: '',
  149. queryParam: {},
  150. // 表头
  151. columns: columns(this),
  152. treeData: [],
  153. url: {
  154. list: '/business/safetool/base/safety/tool/list',
  155. delete: '/business/safetool/base/safety/tool/',
  156. exportXlsUrl: '/business/safetool/base/safety/tool/export',
  157. qrcode: '/st/export',
  158. qrcodeAll: '/st/exportAll',
  159. tree: '/system/dept/treeSelect',
  160. importExcelUrl: `${process.env.VUE_APP_BASE_API}/importExcelUrl`
  161. }
  162. }
  163. },
  164. created() {
  165. this.loadTree()
  166. },
  167. methods: {
  168. handleCancel() {
  169. this.previewImage = ''
  170. this.previewVisible = false
  171. },
  172. perview(record) {
  173. this.previewImage = record.qcodeUrl
  174. this.previewVisible = true
  175. },
  176. loadTree() {
  177. this.treeData = []
  178. getAction(this.url.tree).then((res) => {
  179. if (res.code === 200) {
  180. this.treeData = res.data
  181. }
  182. })
  183. },
  184. handleExportCode() {
  185. if (this.selectedRowKeys.length <= 0) {
  186. this.$message.warning('请选择一条记录!')
  187. return
  188. }
  189. const param = this.getQueryParams()
  190. if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
  191. param['id'] = this.selectedRowKeys.join(',')
  192. }
  193. downFile(this.url.qrcode, param).then((data) => {
  194. if (data.code !== 200) {
  195. this.$message.warning('文件下载失败')
  196. } else {
  197. window.location.href = data.url
  198. }
  199. })
  200. },
  201. handleExportCodeAll() {
  202. downFile(this.url.qrcodeAll).then((data) => {
  203. if (data.code !== 200) {
  204. this.$message.warning('文件下载失败')
  205. } else {
  206. window.location.href = data.url
  207. }
  208. })
  209. }
  210. }
  211. }
  212. </script>
  213. <style scoped>
  214. @import '~@/assets/less/common.less'
  215. </style>