onlinecheck.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <!-- 工种管理 -->
  2. <template>
  3. <div class="work-type">
  4. <template v-if="!addOrUpdateVisible && !detailVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
  6. <el-form-item label="任务号">
  7. <el-input v-model="dataForm.orderCode" placeholder="" clearable />
  8. </el-form-item>
  9. <el-form-item label="图号">
  10. <el-input v-model="dataForm.mapNumber" placeholder="" clearable />
  11. </el-form-item>
  12. <el-form-item label="产品名称">
  13. <el-input v-model="dataForm.productName" placeholder="" clearable />
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button @click="queryData()">查询</el-button>
  17. <el-button type="primary" @click="add()">新增</el-button>
  18. </el-form-item>
  19. </el-form>
  20. <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%">
  21. <el-table-column label="序号" type="index" width="100" align="center">
  22. </el-table-column>
  23. <el-table-column prop="orderCode" header-align="center" align="center" min-width="160"
  24. :show-tooltip-when-overflow="true" label="任务号">
  25. </el-table-column>
  26. <el-table-column prop="mapNumber" header-align="center" align="center" min-width="160"
  27. :show-tooltip-when-overflow="true" label="图号">
  28. </el-table-column>
  29. <el-table-column prop="productName" header-align="center" align="center" min-width="160"
  30. :show-tooltip-when-overflow="true" label="产品名称">
  31. </el-table-column>
  32. <el-table-column prop="productNumber" header-align="center" align="center" min-width="160"
  33. :show-tooltip-when-overflow="true" label="编号">
  34. </el-table-column>
  35. <el-table-column prop="temperature" header-align="center" align="center" min-width="160"
  36. :show-tooltip-when-overflow="true" label="温度">
  37. </el-table-column>
  38. <el-table-column prop="humidity" header-align="center" align="center" min-width="160"
  39. :show-tooltip-when-overflow="true" label="湿度">
  40. </el-table-column>
  41. <el-table-column prop="deliveryDate" header-align="center" align="center" min-width="160"
  42. :show-tooltip-when-overflow="true" label="备注">
  43. </el-table-column>
  44. <el-table-column prop="inspectorName" header-align="center" align="center" min-width="160"
  45. :show-tooltip-when-overflow="true" label="检验员">
  46. </el-table-column>
  47. <el-table-column prop="state" header-align="center" align="center" min-width="160"
  48. :show-tooltip-when-overflow="true" label="状态">
  49. <template slot-scope="scope">
  50. <span>{{ formatState(scope.row) }}</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop="isQualified" header-align="center" align="center" min-width="160"
  54. :show-tooltip-when-overflow="true" label="是否合格">
  55. <template slot-scope="scope">
  56. <span>{{ formatIsQualified(scope.row) }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="inspectionDate" header-align="center" align="center" min-width="160"
  60. :show-tooltip-when-overflow="true" label="校验日期">
  61. </el-table-column>
  62. <el-table-column prop="creatName" header-align="center" align="center" min-width="160"
  63. :show-tooltip-when-overflow="true" label="申请人">
  64. </el-table-column>
  65. <el-table-column prop="createTime" header-align="center" align="center" min-width="160"
  66. :show-tooltip-when-overflow="true" label="申请日期">
  67. </el-table-column>
  68. <el-table-column fixed="right" header-align="center" align="center" width="220" label="操作">
  69. <template slot-scope="scope">
  70. <el-button type="text" size="small" @click="detailHandle(scope.row)">查看</el-button>
  71. <el-button v-if="scope.row.state == 1" type="text" size="small"
  72. @click="importHandle(scope.row)">导入报告</el-button>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
  77. :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
  78. layout="total, sizes, prev, pager, next, jumper">
  79. </el-pagination>
  80. </template>
  81. <!-- 弹窗 -->
  82. <onlinecheck-add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @onChose="onChose" @refreshDataList="getDataList"/>
  83. <onlinecheck-detail v-if="detailVisible" ref="detail" @onChose="onChose" />
  84. <el-dialog title="导入" :visible.sync="importVisible">
  85. <el-upload class="upload-demo" ref="upload" :on-remove="handleRemove" action="#" accept="" :limit="1"
  86. :file-list="fileList" :auto-upload="false" :http-request="handleUpload" v-loading="importLoading">
  87. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  88. <el-button size="small" type="success" @click="submitUpload">开始上传</el-button>
  89. </el-upload>
  90. </el-dialog>
  91. </div>
  92. </template>
  93. <script>
  94. import OnlinecheckAddOrUpdate from "@/views/modules/quality/onlinecheck-add-or-update";
  95. import OnlinecheckDetail from "@/views/modules/quality/onlinecheck-detail";
  96. export default {
  97. name: "plan",
  98. components: {
  99. OnlinecheckAddOrUpdate,
  100. OnlinecheckDetail,
  101. },
  102. data() {
  103. return {
  104. addOrUpdateVisible: false,
  105. detailVisible: false,
  106. importVisible: false,
  107. dataForm: {},
  108. dataList: [],
  109. pageIndex: 1,
  110. pageSize: 10,
  111. totalPage: 0,
  112. dataListLoading: false,
  113. dataListSelections: [],
  114. optionsLevel: [],
  115. importLoading: false,
  116. importData: {},
  117. fileList: [],
  118. stateOption: [
  119. { label: "待检验", value: "1" },
  120. { label: "已检验", value: "2" },
  121. ],
  122. isQualifiedOption: [
  123. { label: "待检验", value: "0" },
  124. { label: "合格", value: "1" },
  125. { label: "不合格", value: "2" },
  126. ],
  127. lastSubmitItem: null,
  128. };
  129. },
  130. created() {
  131. this.getDataList();
  132. },
  133. methods: {
  134. onChose() {
  135. this.addOrUpdateVisible = false;
  136. this.detailVisible = false;
  137. },
  138. // 查询
  139. queryData() {
  140. this.pageIndex = 1;
  141. this.getDataList();
  142. },
  143. // 获取数据列表
  144. getDataList() {
  145. this.dataListLoading = true;
  146. this.addOrUpdateVisible = false;
  147. this.$http({
  148. url: this.$http.adornUrl(`/biz-service/onlineDetection/list`),
  149. method: "get",
  150. params: this.$http.adornParams({
  151. current: this.pageIndex,
  152. size: this.pageSize,
  153. orderCode: this.dataForm.orderCode,
  154. mapNumber: this.dataForm.mapNumber,
  155. productName: this.dataForm.productName,
  156. }),
  157. }).then(({ data }) => {
  158. this.dataListLoading = false;
  159. if (data && data.code === "200") {
  160. this.dataList = data.data.records;
  161. this.totalPage = Number(data.data.total);
  162. } else {
  163. this.dataList = [];
  164. this.totalPage = 0;
  165. }
  166. });
  167. },
  168. // 每页数
  169. sizeChangeHandle(val) {
  170. this.pageSize = val;
  171. this.pageIndex = 1;
  172. this.getDataList();
  173. },
  174. // 当前页
  175. currentChangeHandle(val) {
  176. this.pageIndex = val;
  177. this.getDataList();
  178. },
  179. // 多选
  180. selectionChangeHandle(val) {
  181. this.dataListSelections = val;
  182. },
  183. add() {
  184. this.addOrUpdateVisible = true;
  185. this.$nextTick(() => {
  186. this.$refs.addOrUpdate.init();
  187. });
  188. },
  189. detailHandle(item) {
  190. this.detailVisible = true;
  191. this.$nextTick(() => {
  192. this.$refs.detail.init(item.onlineDetectionId);
  193. });
  194. },
  195. formatState(row) {
  196. if (!row.state) return "";
  197. return this.getStateStr(row.state);
  198. },
  199. getStateStr(state) {
  200. let option = this.stateOption.find((t) => t.value === state);
  201. if (option != null) {
  202. return option.label;
  203. }
  204. return "";
  205. },
  206. formatIsQualified(row) {
  207. if (!row.isQualified) return "";
  208. return this.getIsQualifiedStr(row.isQualified);
  209. },
  210. getIsQualifiedStr(state) {
  211. let option = this.isQualifiedOption.find((t) => t.value === state);
  212. if (option != null) {
  213. return option.label;
  214. }
  215. return "";
  216. },
  217. importHandle(item) {
  218. this.fileList = [];
  219. this.importVisible = true;
  220. this.importData = item;
  221. },
  222. // 上传
  223. submitUpload() {
  224. this.$refs.upload.submit();
  225. this.importVisible = false
  226. this.getDataList()
  227. },
  228. // 移除
  229. handleRemove(file, fileList) {
  230. this.$emit("input", fileList);
  231. },
  232. handleUpload(file) {
  233. if (file == null) {
  234. this.$message.error("请上传文件");
  235. return;
  236. }
  237. this.importLoading = true;
  238. const formData = new FormData();
  239. formData.append("importFile", file.file);
  240. formData.append("onlineDetectionId", this.importData.onlineDetectionId);
  241. this.$http({
  242. url: this.$http.adornUrl(`/biz-service/onlineDetection/importExcel`),
  243. method: "POST",
  244. data: formData,
  245. timeout: 0,
  246. }).then(({ data }) => {
  247. this.importLoading = false;
  248. if (data && data.code === "200") {
  249. this.$message({
  250. message: "导入成功",
  251. type: "success",
  252. duration: 1500,
  253. onClose: () => {
  254. this.importVisible = false;
  255. },
  256. });
  257. } else {
  258. this.$message.error(data.msg);
  259. }
  260. });
  261. },
  262. },
  263. };
  264. </script>
  265. <style scoped></style>