index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="年份" prop="year">
  6. <el-select v-model="queryParams.year" placeholder="请选择年份" clearable>
  7. <el-option v-for="item in year_select" :key="item.value" :label="item.value"
  8. :value="item.value"></el-option>
  9. </el-select>
  10. </el-form-item>
  11. <el-form-item label="月份" prop="month">
  12. <el-select v-model="queryParams.month" placeholder="请选择月份" clearable>
  13. <el-option v-for="item in month_select" :key="item.value" :label="item.value"
  14. :value="item.value"></el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  19. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  20. </el-form-item>
  21. </el-form>
  22. <ele-pro-table ref="tableRef" :columns="columns" :datasource="capacityList" :pageSize="20"
  23. :pageSizes="[20, 30, 40, 50, 100]" row-key="id" @selection-change="handleSelectionChange">
  24. <template v-slot:toolbar>
  25. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
  26. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
  27. @click="handleUpdate">修改</el-button>
  28. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
  29. @click="handleDelete">删除</el-button>
  30. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  31. :disabled="single">详情</el-button>
  32. </template>
  33. <template v-slot:plannedCapacity="{ row }">
  34. {{ row.plannedCapacity }}{{row.plannedCapacityUnit?row.plannedCapacityUnit:''}}
  35. </template>
  36. <template v-slot:averageDailyCapacity="{ row }">
  37. {{ row.averageDailyCapacity }}{{row.plannedCapacityUnit?row.plannedCapacityUnit:''}}
  38. </template>
  39. <template v-slot:action="{ row }">
  40. <el-link type="primary" :underline="false" icon="el-icon-edit" @click="handleUpdate(row)">
  41. 修改
  42. </el-link>
  43. <el-popconfirm class="ele-action" title='是否确认删除此数据?' @confirm="handleDelete(row)">
  44. <template v-slot:reference>
  45. <el-link type="danger" :underline="false" icon="el-icon-delete">
  46. 删除
  47. </el-link>
  48. </template>
  49. </el-popconfirm>
  50. </template>
  51. </ele-pro-table>
  52. <!-- 添加或修改工厂月产能定义对话框 -->
  53. <el-dialog :title="title" :visible.sync="open" width="70%" :close-on-click-modal="false" modal-append-to-body
  54. append-to-body>
  55. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  56. <el-form-item label="年份" prop="year">
  57. <el-select v-model="form.year" placeholder="请选择年份">
  58. <el-option v-for="item in year_select" :key="item.value" :label="item.value"
  59. :value="item.value"></el-option>
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item label="月份" prop="month">
  63. <el-select v-model="form.month" placeholder="请选择月份">
  64. <el-option v-for="item in month_select" :key="item.value" :label="item.value"
  65. :value="item.value"></el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item label="规划产能" prop="plannedCapacity">
  69. <div style="display: flex;align-items: center;justify-content: space-between;">
  70. <el-input v-model="form.plannedCapacity" placeholder="请输入规划产能" style="width: calc(100% - 100px)" />
  71. <DictSelection dictName="计量单位" v-model="form.plannedCapacityUnit" filterable clearable style="width: 100px;">
  72. </DictSelection>
  73. </div>
  74. </el-form-item>
  75. <el-form-item label="工作日天数" prop="expandedCapacity">
  76. <el-input v-model="form.expandedCapacity" placeholder="请输入工作日天数">
  77. <template v-slot:append>天</template>
  78. </el-input>
  79. </el-form-item>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button type="primary" @click="getWorkDay">同步工作日</el-button>
  83. <el-button type="primary" @click="submitForm">确 定</el-button>
  84. <el-button @click="cancel">取 消</el-button>
  85. </div>
  86. </el-dialog>
  87. <el-dialog :title="titleDetail" :visible.sync="openDetail" width="75%" append-to-body>
  88. <el-table v-loading="loading" :data="factory_capacity_detailList" @selection-change="handleSelectionChange">
  89. <el-table-column type="selection" width="55" align="center" />
  90. <el-table-column label="序号" align="center" prop="id" />
  91. <el-table-column label="年份" align="center" prop="year" />
  92. <el-table-column label="月份" align="center" prop="month" />
  93. <el-table-column label="日期" align="center" prop="day" />
  94. <el-table-column label="规划产能" align="center" prop="plannedCapacity" />
  95. <el-table-column label="已排产产能" align="center" prop="plannedSumCapacity" />
  96. <el-table-column label="已排产单号" align="center" prop="plannedOrder" />
  97. <el-table-column label="已排产产能" align="center" prop="plannedOrderCapacity" />
  98. </el-table>
  99. </el-dialog>
  100. </el-card>
  101. </div>
  102. </template>
  103. <script>
  104. import { listSchedule, getSchedule, delSchedule, addSchedule, updateSchedule } from "@/api/aps_workday_schedule/schedule";
  105. import { listCapacity, getCapacity, delCapacity, addCapacity, updateCapacity } from "@/api/aps/capacity";
  106. import { listFactory_capacity_detail, getFactory_capacity_detail, delFactory_capacity_detail, addFactory_capacity_detail, updateFactory_capacity_detail } from "@/api/aps/factory_capacity_detail";
  107. export default {
  108. name: "Capacity",
  109. // dicts: ['year_select','month_select'],
  110. data() {
  111. return {
  112. titleDetail: "工厂能力详情",
  113. openDetail: false,
  114. // 遮罩层
  115. loading: true,
  116. // 选中数组
  117. ids: [],
  118. scheduleList: [],
  119. year_select: [
  120. { "value": 2025 }, { "value": 2026 }, { "value": 2027 }, { "value": 2028 }
  121. ],
  122. month_select: [
  123. { "value": 1 }, { "value": 2 }, { "value": 3 }, { "value": 4 },
  124. { "value": 5 }, { "value": 6 }, { "value": 7 }, { "value": 8 },
  125. { "value": 9 }, { "value": 10 }, { "value": 11 }, { "value": 12 },
  126. ],
  127. // 非单个禁用
  128. single: true,
  129. // 非多个禁用
  130. multiple: true,
  131. // 显示搜索条件
  132. showSearch: true,
  133. // 总条数
  134. total: 0,
  135. // 工厂月产能定义表格数据
  136. capacityList: [],
  137. // 工厂月产能定义详情表格数据
  138. factory_capacity_detailList: [],
  139. // 弹出层标题
  140. title: "",
  141. // 是否显示弹出层
  142. open: false,
  143. // 查询参数
  144. queryParams: {
  145. pageNum: 1,
  146. pageSize: 10,
  147. year: null,
  148. month: null,
  149. plannedCapacity: null,
  150. expandedCapacity: null,
  151. averageDailyCapacity: null
  152. },
  153. // 表单参数
  154. form: {},
  155. // 表单校验
  156. rules: {
  157. },
  158. columns: [
  159. {
  160. width: 45,
  161. type: 'selection',
  162. columnKey: 'selection',
  163. align: 'center',
  164. reserveSelection: true
  165. },
  166. {
  167. prop: 'id',
  168. label: '序号',
  169. align: 'center',
  170. },
  171. {
  172. prop: 'year',
  173. label: '年份',
  174. align: 'center',
  175. },
  176. {
  177. prop: 'month',
  178. label: '月份',
  179. align: 'center',
  180. },
  181. {
  182. prop: 'plannedCapacity',
  183. slot: 'plannedCapacity',
  184. label: '规划产能',
  185. align: 'center',
  186. },
  187. {
  188. prop: 'expandedCapacity',
  189. label: '工作日天数',
  190. align: 'center',
  191. },
  192. {
  193. prop: 'averageDailyCapacity',
  194. label: '平均天产能',
  195. slot: 'averageDailyCapacity',
  196. align: 'center',
  197. },
  198. {
  199. columnKey: 'action',
  200. label: '操作',
  201. width: 150,
  202. align: 'center',
  203. resizable: false,
  204. slot: 'action',
  205. fixed: 'right'
  206. }
  207. ]
  208. };
  209. },
  210. created() {
  211. this.getList();
  212. },
  213. methods: {
  214. /** 查询APS月度班制排班列表 */
  215. getWorkDay() {
  216. this.loading = true;
  217. listSchedule({ "year": this.form.year, "month": this.form.month }).then(response => {
  218. this.scheduleList = response.data;
  219. if (this.scheduleList == null || this.scheduleList.length == 0) {
  220. this.$message.success("没有配置工作日");
  221. this.form.expandedCapacity = 0;
  222. }
  223. else this.form.expandedCapacity = this.scheduleList[0].workdayCount;
  224. });
  225. },
  226. /** 查询工厂月产能定义列表 */
  227. getList() {
  228. this.loading = true;
  229. listCapacity(this.queryParams).then(response => {
  230. console.log(response)
  231. this.capacityList = response.data;
  232. this.total = response.total;
  233. this.loading = false;
  234. });
  235. },
  236. resetForm() {
  237. this.form.year = null;
  238. this.form.month = null;
  239. this.form.plannedCapacity = null;
  240. this.form.expandedCapacity = null;
  241. this.form.averageDailyCapacity = null;
  242. },
  243. // 取消按钮
  244. cancel() {
  245. this.open = false;
  246. this.reset();
  247. },
  248. // 表单重置
  249. reset() {
  250. this.form = {
  251. id: null,
  252. year: null,
  253. month: null,
  254. plannedCapacity: null,
  255. expandedCapacity: null,
  256. averageDailyCapacity: null
  257. };
  258. this.resetForm("form");
  259. },
  260. /** 搜索按钮操作 */
  261. handleQuery() {
  262. this.queryParams.pageNum = 1;
  263. this.getList();
  264. },
  265. /** 重置按钮操作 */
  266. resetQuery() {
  267. this.resetForm("queryForm");
  268. this.handleQuery();
  269. },
  270. // 多选框选中数据
  271. handleSelectionChange(selection) {
  272. this.ids = selection.map(item => item.id)
  273. this.single = selection.length !== 1
  274. this.multiple = !selection.length
  275. },
  276. /** 新增按钮操作 */
  277. handleAdd() {
  278. this.reset();
  279. this.open = true;
  280. this.title = "添加工厂月产能定义";
  281. },
  282. /** 修改按钮操作 */
  283. handleUpdate(row) {
  284. this.reset();
  285. const id = row.id || this.ids
  286. getCapacity(id).then(response => {
  287. this.form = response.data.data;
  288. this.open = true;
  289. this.title = "修改工厂月产能定义";
  290. });
  291. },
  292. /** 提交按钮 */
  293. submitForm() {
  294. this.$refs["form"].validate(valid => {
  295. delete this.form.averageDailyCapacity;
  296. if (valid) {
  297. if (this.form.id != null) {
  298. updateCapacity(this.form).then(response => {
  299. this.$message.success("修改成功");
  300. this.open = false;
  301. this.getList();
  302. });
  303. } else {
  304. addCapacity(this.form).then(response => {
  305. this.$message.success("新增成功");
  306. this.open = false;
  307. this.getList();
  308. });
  309. }
  310. }
  311. });
  312. },
  313. /** 删除按钮操作 */
  314. handleDelete(row) {
  315. const ids = row.id || this.ids;
  316. this.$confirm('是否确认删除工厂月产能定义编号为"' + ids + '"的数据项?').then(function () {
  317. return delCapacity(ids);
  318. }).then(() => {
  319. this.getList();
  320. this.$message.success("删除成功");
  321. }).catch(() => { });
  322. },
  323. /** 导出按钮操作 */
  324. handleExport() {
  325. this.openDetail = true;
  326. this.getDetailList();
  327. // this.download('aps/capacity/export', {
  328. // ...this.queryParams
  329. // }, `capacity_${new Date().getTime()}.xlsx`)
  330. },
  331. /** 查询工厂月产能定义列表 */
  332. getDetailList() {
  333. const ids = this.ids;
  334. this.loading = true;
  335. listFactory_capacity_detail(this.queryParams).then(response => {
  336. this.factory_capacity_detailList = response.data;
  337. this.total = response.total;
  338. this.loading = false;
  339. });
  340. },
  341. }
  342. };
  343. </script>