index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="统一社会信用代码" prop="uniCode" label-width="200">
  5. <el-input
  6. v-model="queryParams.uniCode"
  7. placeholder="请输入统一社会信用代码"
  8. clearable
  9. @keyup.enter="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  14. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="warning"
  21. plain
  22. icon="Download"
  23. @click="handleExport"
  24. :disabled="!xcrFoodInspectionDetailsList.length"
  25. v-hasPermi="['basicData:xcrFoodInspectionDetails:export']"
  26. >导出
  27. </el-button>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-button
  31. type="info"
  32. plain
  33. icon="Upload"
  34. @click="handleImport"
  35. v-hasPermi="['basicData:xcrFoodInspectionDetails:import']"
  36. >导入
  37. </el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="danger"
  42. plain
  43. icon="Delete"
  44. @click="batchDelete"
  45. v-hasPermi="['basicData:xcrFoodInspectionDetails:delete']"
  46. :disabled="ids.length === 0"
  47. >批量删除
  48. </el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-popconfirm
  52. title="你确定清除所有数据?"
  53. confirm-button-text="是的"
  54. cancel-button-text="不是"
  55. :icon="InfoFilled"
  56. icon-color="#626AEF"
  57. @confirm="handleDelete"
  58. >
  59. <template #reference>
  60. <el-button
  61. type="danger"
  62. plain
  63. icon="Delete"
  64. v-hasPermi="['basicData:details:delete']"
  65. >清除全表
  66. </el-button>
  67. </template>
  68. </el-popconfirm>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button type="success" plain icon="Download" @click="downloadTemplate">
  72. 下载导入模板
  73. </el-button>
  74. </el-col>
  75. </el-row>
  76. <el-table v-loading="loading" :data="xcrFoodInspectionDetailsList" height="650" @selection-change="handleSelectionChange">
  77. <el-table-column type="selection" width="55" align="center"/>
  78. <el-table-column label="统一社会信用代码" align="center" prop="uniCode" width="200"/>
  79. <el-table-column label="抽查领域" align="center" prop="inspectionField" :show-overflow-tooltip='true' width="150"/>
  80. <el-table-column label="抽样单位" align="center" prop="samplingUnit" :show-overflow-tooltip='true' width="150"/>
  81. <el-table-column label="被抽样单位所在地市" align="center" prop="cityOfSampledCompany" :show-overflow-tooltip='true' width="150"/>
  82. <el-table-column label="食品大类" align="center" prop="foodCategoryMajor" :show-overflow-tooltip='true' width="150"/>
  83. <el-table-column label="食品亚类" align="center" prop="foodCategorySubmajor" :show-overflow-tooltip='true' width="150"/>
  84. <el-table-column label="食品次亚类" align="center" prop="foodCategorySubminor" :show-overflow-tooltip='true' width="150"/>
  85. <el-table-column label="食品细类" align="center" prop="foodCategoryMinor" :show-overflow-tooltip='true' width="150"/>
  86. <el-table-column label="报告书编号" align="center" prop="reportNumber" :show-overflow-tooltip='true' width="150"/>
  87. <el-table-column label="抽样单号" align="center" prop="sampleNumber" :show-overflow-tooltip='true' width="150"/>
  88. <el-table-column label="产品名称" align="center" prop="productName" :show-overflow-tooltip='true' width="150"/>
  89. <el-table-column label="规格型号" align="center" prop="specificationModel" :show-overflow-tooltip='true' width="150"/>
  90. <el-table-column label="商标" align="center" prop="trademark" :show-overflow-tooltip='true' width="150"/>
  91. <el-table-column label="生产日期" align="center" prop="productionDate" width="180">
  92. <template #default="scope">
  93. <span>{{ parseTime(scope.row.productionDate, '{y}-{m}-{d}') }}</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="抽样日期" align="center" prop="samplingDate" width="180">
  97. <template #default="scope">
  98. <span>{{ parseTime(scope.row.samplingDate, '{y}-{m}-{d}') }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="受检单位" align="center" prop="inspectedCompanyName" :show-overflow-tooltip='true' width="150"/>
  102. <el-table-column label="受检单位地址" align="center" prop="inspectedCompanyAddress" :show-overflow-tooltip='true' width="150"/>
  103. <el-table-column label="受检单位联系人" align="center" prop="inspectedCompanyContactPerson" :show-overflow-tooltip='true' width="150"/>
  104. <el-table-column label="受检单位电话" align="center" prop="inspectedCompanyPhone" :show-overflow-tooltip='true' width="150"/>
  105. <el-table-column label="生产单位" align="center" prop="manufacturingCompanyName" :show-overflow-tooltip='true' width="150"/>
  106. <el-table-column label="生产单位地址" align="center" prop="manufacturingCompanyAddress" :show-overflow-tooltip='true' width="150"/>
  107. <el-table-column label="检验项目" align="center" prop="inspectionItems" :show-overflow-tooltip='true' width="150"/>
  108. <el-table-column label="检验结果" align="center" prop="inspectionResult" :show-overflow-tooltip='true' width="150"/>
  109. <el-table-column label="不合格项目" align="center" prop="nonconformityItems" :show-overflow-tooltip='true' width="150"/>
  110. <el-table-column label="标准要求" align="center" prop="standardRequirements" :show-overflow-tooltip='true' width="150"/>
  111. <el-table-column label="实测值" align="center" prop="measuredValue" :show-overflow-tooltip='true' width="150"/>
  112. <el-table-column label="项目单位" align="center" prop="projectUnits" :show-overflow-tooltip='true' width="150"/>
  113. <el-table-column label="任务性质" align="center" prop="taskNature" :show-overflow-tooltip='true' width="150"/>
  114. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip='true' width="150"/>
  115. </el-table>
  116. <div style="position: fixed;bottom: 20px;right: 10px;">
  117. <pagination
  118. v-show="total>0"
  119. :total="total"
  120. v-model:page="queryParams.pageNum"
  121. v-model:limit="queryParams.pageSize"
  122. @pagination="getList"
  123. />
  124. </div>
  125. <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
  126. <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
  127. :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
  128. :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  129. <el-icon class="el-icon--upload">
  130. <upload-filled/>
  131. </el-icon>
  132. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  133. <template #tip>
  134. <div class="el-upload__tip text-center">
  135. <span>仅允许导入xls、xlsx格式文件。</span>
  136. </div>
  137. </template>
  138. </el-upload>
  139. <template #footer>
  140. <div class="dialog-footer">
  141. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  142. <el-button @click="upload.open = false">取 消</el-button>
  143. </div>
  144. </template>
  145. </el-dialog>
  146. </div>
  147. </template>
  148. <script setup name="Details">
  149. import {
  150. listDetails,
  151. getDetails,
  152. delDetails,
  153. delDetailsBatch
  154. } from "@/api/basicData/xcrFoodInspectionDetails";
  155. import {reactive, ref, toRaw} from "vue";
  156. import {getToken} from "@/utils/auth";
  157. import {ElMessage} from "element-plus";
  158. import {likeQueryMethod} from "@/utils/likeQueryMethod";
  159. const {proxy} = getCurrentInstance();
  160. const xcrFoodInspectionDetailsList = ref([]);
  161. const open = ref(false);
  162. const loading = ref(true);
  163. const showSearch = ref(true);
  164. const ids = ref([]);
  165. const single = ref(true);
  166. const multiple = ref(true);
  167. const total = ref(0);
  168. const title = ref("");
  169. const upload = reactive({
  170. // 是否显示弹出层(用户导入)
  171. open: false,
  172. // 弹出层标题(用户导入)
  173. title: '',
  174. // 是否禁用上传
  175. isUploading: false,
  176. // 设置上传的请求头部
  177. headers: {Authorization: getToken()},
  178. // 上传的地址
  179. url: import.meta.env.VITE_APP_BASE_API + '/basicData/xcrFoodInspectionDetails/importData'
  180. })
  181. const handleFileSuccess = (e) => {
  182. if (e.code == 200) {
  183. ElMessage({
  184. type: "success",
  185. message: e.msg
  186. })
  187. getList()
  188. proxy.$refs['uploadRef']?.clearFiles()
  189. } else {
  190. ElMessage({
  191. type: "error",
  192. message: e.msg
  193. })
  194. proxy.$refs['uploadRef']?.clearFiles()
  195. }
  196. }
  197. function submitFileForm() {
  198. proxy.$refs['uploadRef']?.submit();
  199. upload.open = false;
  200. }
  201. function handleImport() {
  202. upload.open = true
  203. }
  204. const data = reactive({
  205. form: {},
  206. queryParams: {
  207. pageNum: 1,
  208. pageSize: 20,
  209. inspectionField: null,
  210. samplingUnit: null,
  211. cityOfSampledCompany: null,
  212. foodCategoryMajor: null,
  213. foodCategorySubmajor: null,
  214. foodCategorySubminor: null,
  215. foodCategoryMinor: null,
  216. reportNumber: null,
  217. sampleNumber: null,
  218. productName: null,
  219. specificationModel: null,
  220. trademark: null,
  221. productionDate: null,
  222. samplingDate: null,
  223. inspectedCompanyName: null,
  224. inspectedCompanyAddress: null,
  225. inspectedCompanyContactPerson: null,
  226. inspectedCompanyPhone: null,
  227. manufacturingCompanyName: null,
  228. manufacturingCompanyAddress: null,
  229. inspectionItems: null,
  230. inspectionResult: null,
  231. nonconformityItems: null,
  232. standardRequirements: null,
  233. measuredValue: null,
  234. projectUnits: null,
  235. taskNature: null,
  236. remarks: null,
  237. uniCode: ''
  238. },
  239. rules: {
  240. }
  241. });
  242. const {queryParams, form, rules} = toRefs(data);
  243. /** 查询流通抽样检验工作汇总列表 */
  244. function getList() {
  245. loading.value = true;
  246. let toServerObj = likeQueryMethod('uni_code', queryParams.value.uniCode, queryParams.value.pageNum, queryParams.value.pageSize);
  247. listDetails(toServerObj).then(response => {
  248. xcrFoodInspectionDetailsList.value = response.records;
  249. total.value = response.total;
  250. loading.value = false;
  251. });
  252. }
  253. // 表单重置
  254. function reset() {
  255. form.value = {
  256. xhCodeId: null,
  257. inspectionField: null,
  258. samplingUnit: null,
  259. cityOfSampledCompany: null,
  260. foodCategoryMajor: null,
  261. foodCategorySubmajor: null,
  262. foodCategorySubminor: null,
  263. foodCategoryMinor: null,
  264. reportNumber: null,
  265. sampleNumber: null,
  266. productName: null,
  267. specificationModel: null,
  268. trademark: null,
  269. productionDate: null,
  270. samplingDate: null,
  271. inspectedCompanyName: null,
  272. inspectedCompanyAddress: null,
  273. inspectedCompanyContactPerson: null,
  274. inspectedCompanyPhone: null,
  275. manufacturingCompanyName: null,
  276. manufacturingCompanyAddress: null,
  277. inspectionItems: null,
  278. inspectionResult: null,
  279. nonconformityItems: null,
  280. standardRequirements: null,
  281. measuredValue: null,
  282. projectUnits: null,
  283. taskNature: null,
  284. remarks: null,
  285. uniCode: ''
  286. };
  287. proxy.resetForm("xcrFoodInspectionDetailsRef");
  288. }
  289. /** 搜索按钮操作 */
  290. function handleQuery() {
  291. queryParams.value.pageNum = 1;
  292. getList();
  293. }
  294. /** 重置按钮操作 */
  295. function resetQuery() {
  296. proxy.resetForm("queryRef");
  297. handleQuery();
  298. }
  299. // 多选框选中数据
  300. function handleSelectionChange(selection) {
  301. ids.value = selection.map(item => item.xhCodeId);
  302. single.value = selection.length != 1;
  303. multiple.value = !selection.length;
  304. }
  305. /** 删除按钮操作 */
  306. async function handleDelete(row) {
  307. const res = await delDetails();
  308. if(res.code == 200){
  309. ElMessage({
  310. type:'success',
  311. message:'删除成功'
  312. })
  313. getList();
  314. }
  315. }
  316. /** 批量删除*/
  317. const batchDelete = (row)=>{
  318. const idsToS = row.xhCodeId || ids.value;
  319. (proxy.$modal).confirm('是否确认删除这' + idsToS.length+'条的数据项?').then(function() {
  320. return delDetailsBatch(toRaw(idsToS));
  321. }).then(() => {
  322. getList();
  323. proxy.$modal.msgSuccess("删除成功");
  324. }).catch(() => {});
  325. }
  326. /** 导出按钮操作 */
  327. function handleExport() {
  328. proxy.download('basicData/xcrFoodInspectionDetails/export', {
  329. ...queryParams.value
  330. }, `流通抽样检验工作汇总_${new Date().getTime()}.xlsx`)
  331. }
  332. const downloadTemplate = ()=>{
  333. proxy.download('basicData/xcrFoodInspectionDetails/getUploadTemplate',{}, `流通抽样检验工作汇总模板.xlsx`)
  334. }
  335. getList();
  336. </script>