checkProductionPreparations.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <ele-modal
  3. width="65vw"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :close-on-click-modal="false"
  7. row-key="code"
  8. custom-class="ele-dialog-form"
  9. title="生产前准备"
  10. @closed="onClose"
  11. append-to-body
  12. :maxable="true"
  13. >
  14. <ele-pro-table
  15. ref="table"
  16. :columns="columns"
  17. :initLoad="false"
  18. :datasource="datasource"
  19. :selection.sync="selection"
  20. row-key="id"
  21. @columns-change="handleColumnChange"
  22. :cacheKey="cacheKeyUrl"
  23. :page-size="20"
  24. >
  25. <template v-slot:toolbar>
  26. <el-button type="primary" size="mini" @click="batchKittingComplete"
  27. >批量齐套检查</el-button
  28. >
  29. </template>
  30. <template v-slot:preType="{ row }">
  31. <span>{{ getTypeLabel(row.preType) }}</span>
  32. </template>
  33. <template v-slot:statusStr="{ row }">
  34. <span v-if="row.statusStr == '缺料'" style="color: red">{{
  35. row.statusStr
  36. }}</span>
  37. <span v-else-if="row.statusStr == '不齐套'" style="color: orange">{{
  38. row.statusStr
  39. }}</span>
  40. <span v-else style="color: green">{{ row.statusStr }}</span>
  41. </template>
  42. <template v-slot:action="{ row, $index }">
  43. <el-link
  44. type="primary"
  45. :underline="false"
  46. @click="kittingComplete(row, $index)"
  47. >
  48. 齐套检查
  49. </el-link>
  50. <el-link
  51. type="primary"
  52. :underline="false"
  53. @click="taskAssignment"
  54. v-if="row.statusStr == '缺料' && row.preType == '6'"
  55. >
  56. 任务派单
  57. </el-link>
  58. </template>
  59. </ele-pro-table>
  60. <el-dialog
  61. title="任务派单"
  62. v-if="dialogVisible"
  63. :visible.sync="dialogVisible"
  64. width="30%"
  65. :before-close="handleClose"
  66. append-to-body
  67. >
  68. <el-form ref="form" :model="form" label-width="100px" :rules="rules">
  69. <el-form-item label="分管部门:">
  70. <ele-tree-select
  71. clearable
  72. :data="groupList"
  73. filterable
  74. v-model="form.executeGroupId"
  75. valueKey="id"
  76. labelKey="name"
  77. placeholder="请选择"
  78. @change="change_principalDep"
  79. default-expand-all
  80. />
  81. </el-form-item>
  82. <el-form-item label="技术员:" prop="executorId">
  83. <el-select
  84. v-model="form.executorId"
  85. placeholder="请选择"
  86. style="width: 100%"
  87. @change="leaderListChange"
  88. >
  89. <el-option
  90. v-for="item in leaderList"
  91. :key="item.id"
  92. :label="item.name"
  93. :value="item.id"
  94. >
  95. </el-option>
  96. </el-select>
  97. </el-form-item>
  98. <el-form-item label="备注">
  99. <el-input
  100. type="textarea"
  101. :rows="4"
  102. placeholder="请输入内容"
  103. v-model="form.remake"
  104. >
  105. </el-input>
  106. </el-form-item>
  107. </el-form>
  108. <span slot="footer" class="dialog-footer">
  109. <el-button @click="dialogVisible = false">取 消</el-button>
  110. <el-button type="primary" @click="batchConfirm">确 定</el-button>
  111. </span>
  112. </el-dialog>
  113. <kitting-complete ref="kittingCompleteRef"></kitting-complete>
  114. </ele-modal>
  115. </template>
  116. <script>
  117. import { completenessCheck, taskReleaseWork } from '@/api/productionPlan';
  118. import { listOrganizations, getUserPage } from '@/api/system/organization';
  119. import kittingComplete from './kittingComplete.vue';
  120. export default {
  121. components: { kittingComplete },
  122. data() {
  123. // 1主材料 2辅材料 3工装 4工艺文件 5NC代码 6人员
  124. return {
  125. visible: false,
  126. cacheKeyUrl: 'checkProductionPreparationsKey',
  127. selection: [],
  128. planId: '',
  129. typeList: [
  130. {
  131. value: 1,
  132. label: '主材料齐套'
  133. },
  134. {
  135. value: 2,
  136. label: '辅材料齐套'
  137. },
  138. {
  139. value: 3,
  140. label: '工装齐套'
  141. },
  142. {
  143. value: 4,
  144. label: '工艺文件齐套'
  145. },
  146. {
  147. value: 5,
  148. label: 'NC代码齐套'
  149. },
  150. {
  151. value: 6,
  152. label: '人员齐套'
  153. }
  154. ],
  155. groupList: [],
  156. leaderList: [],
  157. form: {
  158. executeGroupName: '',
  159. executeGroupId: '',
  160. executorName: '',
  161. executorId: '',
  162. remake: ''
  163. },
  164. dialogVisible: false,
  165. rules: {
  166. executorId: [
  167. { required: true, message: '请选择技术人员', trigger: 'blur' }
  168. ]
  169. },
  170. itemData: {}
  171. };
  172. },
  173. created() {
  174. console.log(this.$store.state.user.info, '用户信息');
  175. this.getGs();
  176. },
  177. computed: {
  178. columns() {
  179. return [
  180. {
  181. width: 45,
  182. type: 'selection',
  183. columnKey: 'selection',
  184. align: 'center',
  185. fixed: 'left',
  186. reserveSelection: true
  187. },
  188. {
  189. width: 55,
  190. type: 'index',
  191. columnKey: 'index',
  192. align: 'center',
  193. label: '序号',
  194. fixed: 'left'
  195. },
  196. {
  197. prop: 'preType',
  198. slot: 'preType',
  199. align: 'center',
  200. label: '名称'
  201. },
  202. {
  203. prop: 'statusStr',
  204. slot: 'statusStr',
  205. align: 'center',
  206. label: '状态'
  207. },
  208. {
  209. prop: 'approveDate',
  210. align: 'center',
  211. label: '校验时间'
  212. },
  213. {
  214. prop: 'approveName',
  215. align: 'center',
  216. label: '校验人',
  217. showOverflowTooltip: true
  218. },
  219. {
  220. columnKey: 'action',
  221. label: '操作',
  222. align: 'center',
  223. resizable: false,
  224. slot: 'action',
  225. fixed: 'right',
  226. showOverflowTooltip: true
  227. }
  228. ];
  229. }
  230. },
  231. methods: {
  232. datasource({ page, where, limit }) {
  233. let pageNum = page;
  234. let size = limit;
  235. where.planId = this.planId;
  236. const res = completenessCheck({ ...where, pageNum, size });
  237. return res;
  238. },
  239. reload(where) {
  240. this.$nextTick(() => {
  241. if (this.$refs.table && this.$refs.table.reload)
  242. this.$refs.table.reload({ page: 1, where: where });
  243. });
  244. },
  245. async getGs() {
  246. await listOrganizations().then((list) => {
  247. this.groupList = this.$util.toTreeData({
  248. data: list,
  249. idField: 'id',
  250. parentIdField: 'parentId'
  251. });
  252. });
  253. },
  254. getTypeLabel(value) {
  255. const item = this.typeList.find((it) => it.value === value);
  256. return item ? item.label : '';
  257. },
  258. open(item) {
  259. this.visible = true;
  260. this.itemData = item;
  261. this.planId = item.id;
  262. if (this.planId) {
  263. this.reload();
  264. }
  265. },
  266. handleColumnChange() {},
  267. onClose() {
  268. this.planId = '';
  269. this.visible = false;
  270. },
  271. handleClose() {
  272. this.dialogVisible = false;
  273. },
  274. kittingComplete(item, index) {
  275. if (item.preType == '5' || item.preType == '6') {
  276. this.$confirm('是否确认齐套?', '提示', {
  277. confirmButtonText: '齐套',
  278. cancelButtonText: '不齐套',
  279. type: 'warning'
  280. })
  281. .then(() => {
  282. // approveDate: null;
  283. // approveId: '';
  284. // approveName: '';
  285. item.approveDate = this.getNowDate();
  286. item.statusStr = '齐套';
  287. this.$forceUpdate();
  288. })
  289. .catch(() => {
  290. item.approveDate = this.getNowDate();
  291. item.statusStr = '不齐套';
  292. this.$forceUpdate();
  293. });
  294. } else {
  295. const list = [this.itemData];
  296. this.$refs.kittingCompleteRef.open(list);
  297. }
  298. },
  299. getNowDate() {
  300. const now = new Date();
  301. const year = now.getFullYear();
  302. const month = String(now.getMonth() + 1).padStart(2, '0');
  303. const day = String(now.getDate()).padStart(2, '0');
  304. const hour = String(now.getHours()).padStart(2, '0');
  305. const minute = String(now.getMinutes()).padStart(2, '0');
  306. const second = String(now.getSeconds()).padStart(2, '0');
  307. const currentTime = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  308. return currentTime;
  309. },
  310. taskAssignment() {
  311. this.dialogVisible = true;
  312. },
  313. change_principalDep(id) {
  314. const node = this.findNodeById(this.groupList, id);
  315. this.form.executeGroupName = node ? node.name : '';
  316. this.form.executorId = '';
  317. this.form.executorName = '';
  318. this.getUserPage();
  319. },
  320. leaderListChange(id) {
  321. const item = this.leaderList.find((it) => it.id === id);
  322. this.form.executorName = item.name;
  323. },
  324. findNodeById(list, id) {
  325. for (const item of list) {
  326. if (item.id === id) return item;
  327. if (item.children) {
  328. const found = this.findNodeById(item.children, id);
  329. if (found) return found;
  330. }
  331. }
  332. return null;
  333. },
  334. async getUserPage() {
  335. if (!this.form.executeGroupId) return (this.leaderList = []);
  336. let par = {
  337. groupId: this.form.executeGroupId,
  338. size: 999
  339. };
  340. await getUserPage(par).then((res) => {
  341. this.leaderList = res.list;
  342. });
  343. },
  344. async batchConfirm() {
  345. const valid = await this.$refs.form.validate().catch(() => false);
  346. if (!valid) return;
  347. const loading = this.$loading({
  348. lock: true,
  349. text: '派单中...',
  350. spinner: 'el-icon-loading',
  351. background: 'rgba(0, 0, 0, 0.7)'
  352. });
  353. await taskReleaseWork({
  354. ...this.form,
  355. productionPlanId: this.itemData.id,
  356. eventType: 1
  357. })
  358. .then(() => {
  359. loading.close();
  360. this.form = {
  361. executeGroupName: '',
  362. executeGroupId: '',
  363. executorName: '',
  364. executorId: '',
  365. remake: ''
  366. };
  367. this.dialogVisible = false;
  368. this.reload();
  369. })
  370. .catch(() => {
  371. loading.close();
  372. });
  373. },
  374. batchKittingComplete() {}
  375. }
  376. };
  377. </script>
  378. <style></style>