index.vue 11 KB

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