index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="100px"
  10. >
  11. <el-form-item label="SOP编号" prop="sopCode">
  12. <el-input
  13. v-model="queryParams.sopCode"
  14. placeholder="请输入SOP编号"
  15. clearable
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="SOP名称" prop="sopName">
  20. <el-input
  21. v-model="queryParams.sopName"
  22. placeholder="请输入SOP名称"
  23. clearable
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="状态" prop="sopStatus">
  28. <el-select v-model="queryParams.sopStatus" placeholder="状态">
  29. <el-option
  30. v-for="dict in dict.type.mes_calendar_type"
  31. :key="dict.value"
  32. :label="dict.label"
  33. :value="dict.value"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="车间名称" prop="workshopName">
  38. <el-select
  39. v-model="queryParams.workshopName"
  40. placeholder="请选择车间名称"
  41. @change="workShopChange"
  42. >
  43. <el-option
  44. v-for="item in this.workshopList"
  45. :key="item.key"
  46. :label="item.label"
  47. :value="item.value"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="产线" prop="workareaName">
  52. <el-select v-model="queryParams.workareaName" placeholder="请选择产线">
  53. <el-option
  54. v-for="dict in this.workareaList"
  55. :key="dict.value"
  56. :label="dict.label"
  57. :value="dict.value"
  58. />
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item label="创建时间">
  62. <el-date-picker
  63. style="width: 218px"
  64. v-model="createTime"
  65. type="daterange"
  66. align="right"
  67. unlink-panels
  68. range-separator="至"
  69. start-placeholder="开始日期"
  70. end-placeholder="结束日期"
  71. :picker-options="pickerOptions"
  72. >
  73. </el-date-picker>
  74. </el-form-item>
  75. <el-form-item label="SOP类型" prop="sopType">
  76. <el-select v-model="queryParams.sopType" placeholder="请选择SOP类型">
  77. <el-option
  78. v-for="dict in dict.type.mes_calendar_type"
  79. :key="dict.value"
  80. :label="dict.label"
  81. :value="dict.value"
  82. />
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item>
  86. <el-button
  87. type="primary"
  88. icon="el-icon-search"
  89. size="mini"
  90. @click="handleQuery"
  91. >搜索</el-button
  92. >
  93. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  94. >重置</el-button
  95. >
  96. </el-form-item>
  97. </el-form>
  98. <el-row :gutter="10" class="mb8">
  99. <el-col :span="1.5">
  100. <el-button
  101. type="primary"
  102. plain
  103. icon="el-icon-plus"
  104. size="mini"
  105. @click="handleAdd"
  106. v-hasPermi="['mes:sop:sopm:add']"
  107. >新增
  108. </el-button>
  109. </el-col>
  110. <el-col :span="1.5">
  111. <el-button
  112. type="danger"
  113. plain
  114. icon="el-icon-delete"
  115. size="mini"
  116. :disabled="multiple"
  117. @click="handleDelete"
  118. v-hasPermi="['mes:sop:sopm:batchremove']"
  119. >批量删除
  120. </el-button>
  121. </el-col>
  122. <!-- <el-col :span="1.5">-->
  123. <!-- <el-button-->
  124. <!-- type="warning"-->
  125. <!-- plain-->
  126. <!-- icon="el-icon-download"-->
  127. <!-- size="mini"-->
  128. <!-- @click="handleExport"-->
  129. <!-- v-hasPermi="['mes:cal:team:export']"-->
  130. <!-- >导出</el-button>-->
  131. <!-- </el-col>-->
  132. <right-toolbar
  133. :showSearch.sync="showSearch"
  134. @queryTable="getList"
  135. ></right-toolbar>
  136. </el-row>
  137. <el-table
  138. v-loading="loading"
  139. :data="sopList"
  140. @selection-change="handleSelectionChange"
  141. >
  142. <el-table-column type="selection" width="55" align="center" />
  143. <el-table-column label="SOP编号" align="center" prop="sopCode">
  144. <!-- <template slot-scope="scope">
  145. <el-button
  146. type="text"
  147. @click="handleView(scope.row)"
  148. v-hasPermi="['mes:sop:sopm:query']"
  149. >{{ scope.row.teamCode }}
  150. </el-button>
  151. </template> -->
  152. </el-table-column>
  153. <el-table-column label="SOP名称" align="center" prop="sopName" />
  154. <el-table-column label="状态" align="center" prop="sopStatus">
  155. <template slot-scope="scope">
  156. <dict-tag
  157. :options="dict.type.mes_calendar_type"
  158. :value="scope.row.sopStatus"
  159. />
  160. </template>
  161. </el-table-column>
  162. <el-table-column label="车间名称" align="center" prop="workshopName">
  163. </el-table-column>
  164. <el-table-column label="SOP类型" align="center" prop="sopType">
  165. </el-table-column>
  166. <el-table-column label="产线" align="center" prop="workareaName">
  167. </el-table-column>
  168. <el-table-column label="隔离点数量" align="center" prop="pointCount">
  169. </el-table-column>
  170. <el-table-column label="创建时间" align="center" prop="createTime">
  171. </el-table-column>
  172. <el-table-column
  173. label="操作"
  174. align="center"
  175. class-name="small-padding fixed-width"
  176. >
  177. <template slot-scope="scope">
  178. <el-button
  179. size="mini"
  180. type="text"
  181. icon="el-icon-edit"
  182. @click="handleUpdate(scope.row)"
  183. v-hasPermi="['mes:sop:sopm:edit']"
  184. >编辑
  185. </el-button>
  186. <el-button
  187. size="mini"
  188. type="text"
  189. icon="el-icon-edit"
  190. @click="handleUpdate(scope.row)"
  191. v-hasPermi="['mes:sop:sopm:progress']"
  192. >执行
  193. </el-button>
  194. <el-button
  195. size="mini"
  196. type="text"
  197. icon="el-icon-delete"
  198. @click="handleDelete(scope.row)"
  199. v-hasPermi="['mes:sop:sopm:remove']"
  200. >删除
  201. </el-button>
  202. </template>
  203. </el-table-column>
  204. </el-table>
  205. <pagination
  206. v-show="total > 0"
  207. :total="total"
  208. :page.sync="queryParams.current"
  209. :limit.sync="queryParams.size"
  210. @pagination="getList"
  211. />
  212. </div>
  213. </template>
  214. <script>
  215. import {
  216. listTeam,
  217. getTeam,
  218. delTeam,
  219. addTeam,
  220. updateTeam,
  221. } from "@/api/mes/cal/team";
  222. import {
  223. workshoplistAll,
  224. getIsWorkareaList,
  225. } from "@/api/mes/spm/segregationPoint";
  226. import { getIsSopPage } from "@/api/mes/sop/sopindex";
  227. import { genCode } from "@/api/system/autocode/rule";
  228. export default {
  229. name: "Team",
  230. dicts: ["mes_calendar_type"],
  231. data() {
  232. return {
  233. //自动生成编码
  234. autoGenFlag: false,
  235. optType: undefined,
  236. // 遮罩层
  237. loading: true,
  238. // 选中数组
  239. ids: [],
  240. // 非单个禁用
  241. single: true,
  242. // 非多个禁用
  243. multiple: true,
  244. // 显示搜索条件
  245. showSearch: true,
  246. // 总条数
  247. total: 0,
  248. // 班组表格数据
  249. sopList: [],
  250. // 弹出层标题
  251. title: "",
  252. // 是否显示弹出层
  253. open: false,
  254. // 车间数据
  255. workshopList: [],
  256. // 工作区域数据
  257. workareaList: [],
  258. // 查询参数
  259. createTime: "",
  260. queryParams: {
  261. current: 1,
  262. size: 10,
  263. sopCode: null,
  264. sopName: null,
  265. sopStatus: null,
  266. workshopName: null,
  267. workareaName: null,
  268. startTime: "",
  269. endTime: "",
  270. },
  271. pickerOptions: {
  272. shortcuts: [
  273. {
  274. text: "最近一周",
  275. onClick(picker) {
  276. const end = new Date();
  277. const start = new Date();
  278. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  279. picker.$emit("pick", [start, end]);
  280. },
  281. },
  282. {
  283. text: "最近一个月",
  284. onClick(picker) {
  285. const end = new Date();
  286. const start = new Date();
  287. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  288. picker.$emit("pick", [start, end]);
  289. },
  290. },
  291. {
  292. text: "最近三个月",
  293. onClick(picker) {
  294. const end = new Date();
  295. const start = new Date();
  296. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  297. picker.$emit("pick", [start, end]);
  298. },
  299. },
  300. ],
  301. },
  302. // 表单参数
  303. form: {},
  304. };
  305. },
  306. created() {
  307. this.getList();
  308. this.getworkShop();
  309. },
  310. methods: {
  311. // 格式化日期查询数据
  312. formatDate(date) {
  313. if (date && date instanceof Date && !isNaN(date)) {
  314. // 使用本地时间
  315. return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
  316. 2,
  317. "0"
  318. )}-${String(date.getDate()).padStart(2, "0")}`;
  319. }
  320. return null;
  321. },
  322. /** 查询sop列表 */
  323. getList() {
  324. this.loading = true;
  325. // 格式化日期并更新queryParams
  326. if (Array.isArray(this.createTime) && this.createTime.length === 2) {
  327. this.queryParams.startTime = this.formatDate(this.createTime[0]);
  328. this.queryParams.endTime = this.formatDate(this.createTime[1]);
  329. }
  330. getIsSopPage(this.queryParams).then((response) => {
  331. console.log(response, "接口返回结果");
  332. this.sopList = response.data.records;
  333. this.total = response.data.total;
  334. this.loading = false;
  335. });
  336. },
  337. // 获取车间数据
  338. getworkShop() {
  339. workshoplistAll().then((response) => {
  340. // console.log(response, "获取车间数据");
  341. this.workshopList = response.data.map((item) => {
  342. return {
  343. label: item.workshopName,
  344. value: item.workshopId,
  345. key: item.workshopCode,
  346. };
  347. });
  348. });
  349. },
  350. // 所属车间下拉改变工作区域内容
  351. workShopChange() {
  352. this.getworkArea();
  353. },
  354. // 获取工作区域数据
  355. getworkArea() {
  356. const workshopId = this.form.workshopId;
  357. if (workshopId) {
  358. getIsWorkareaList(workshopId).then((response) => {
  359. // console.log(response, "获取工作区域数据");
  360. this.workareaList = response.data.map((item) => {
  361. return {
  362. label: item.workareaName,
  363. value: item.workareaId,
  364. key: item.workareaCode,
  365. };
  366. });
  367. });
  368. }
  369. },
  370. // 取消按钮
  371. cancel() {
  372. this.open = false;
  373. this.reset();
  374. },
  375. // 表单重置
  376. reset() {
  377. this.form = {
  378. sopCode: null,
  379. sopName: null,
  380. sopStatus: null,
  381. workshopName: null,
  382. workareaName: null,
  383. pointCount: null,
  384. sopType: null,
  385. createTime: null,
  386. };
  387. this.resetForm("form");
  388. },
  389. /** 搜索按钮操作 */
  390. handleQuery() {
  391. this.queryParams.current = 1;
  392. this.getList();
  393. },
  394. /** 重置按钮操作 */
  395. resetQuery() {
  396. this.createTime = "";
  397. (this.queryParams.startTime = ""),
  398. (this.queryParams.endTime = ""),
  399. this.resetForm("queryForm");
  400. this.handleQuery();
  401. },
  402. // 多选框选中数据
  403. handleSelectionChange(selection) {
  404. this.ids = selection.map((item) => item.teamId);
  405. this.single = selection.length !== 1;
  406. this.multiple = !selection.length;
  407. },
  408. /** 新增按钮操作 */
  409. handleAdd() {
  410. this.reset();
  411. this.open = true;
  412. this.$router.push("/mes/sop/sopm/NewSop");
  413. this.title = "添加隔离点";
  414. this.optType = "add";
  415. },
  416. // 查询明细按钮操作
  417. // handleView(row) {
  418. // this.reset();
  419. // const teamId = row.teamId || this.ids;
  420. // getTeam(teamId).then((response) => {
  421. // this.form = response.data;
  422. // this.open = true;
  423. // this.title = "查看班组";
  424. // this.optType = "view";
  425. // });
  426. // },
  427. /** 修改按钮操作 */
  428. handleUpdate(row) {
  429. this.reset();
  430. const teamId = row.teamId || this.ids;
  431. getTeam(teamId).then((response) => {
  432. this.form = response.data;
  433. this.open = true;
  434. this.title = "修改隔离点信息";
  435. this.optType = "edit";
  436. });
  437. },
  438. /** 提交按钮 */
  439. submitForm() {
  440. this.$refs["form"].validate((valid) => {
  441. if (valid) {
  442. if (this.form.teamId != null) {
  443. updateTeam(this.form).then((response) => {
  444. this.$modal.msgSuccess("修改成功");
  445. this.open = false;
  446. this.getList();
  447. });
  448. } else {
  449. addTeam(this.form).then((response) => {
  450. this.$modal.msgSuccess("新增成功");
  451. this.open = false;
  452. this.getList();
  453. });
  454. }
  455. }
  456. });
  457. },
  458. /** 删除按钮操作 */
  459. handleDelete(row) {
  460. const teamIds = row.teamId || this.ids;
  461. this.$modal
  462. .confirm('是否确认删除班组编号为"' + teamIds + '"的数据项?')
  463. .then(function () {
  464. return delTeam(teamIds);
  465. })
  466. .then(() => {
  467. this.getList();
  468. this.$modal.msgSuccess("删除成功");
  469. })
  470. .catch(() => {});
  471. },
  472. /** 导出按钮操作 */
  473. // handleExport() {
  474. // this.download(
  475. // "cal/team/export",
  476. // {
  477. // ...this.queryParams,
  478. // },
  479. // `team_${new Date().getTime()}.xlsx`
  480. // );
  481. // },
  482. },
  483. };
  484. </script>
  485. <style lang="scss" src="@/assets/styles/dialog-title.scss" scoped>
  486. .el-input-width {
  487. width: 380px !important;
  488. }
  489. </style>