edit.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. class="ele-dialog-form"
  5. :title="title"
  6. :visible.sync="visible"
  7. :before-close="handleClose"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. width="70%"
  11. :maxable="true"
  12. >
  13. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  14. <el-card
  15. shadow="never"
  16. header="基本信息"
  17. body-style="padding: 22px 22px 0 22px;"
  18. >
  19. <el-row>
  20. <el-col :span="8">
  21. <el-form-item label="工位编码:" prop="code">
  22. <el-input
  23. clearable
  24. @click.native="openCode"
  25. v-model="form.code"
  26. placeholder="请输入"
  27. :disabled="type === 'edit'"
  28. />
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="8">
  32. <el-form-item label="工位名称:" prop="name">
  33. <el-input
  34. clearable
  35. :maxlength="20"
  36. v-model="form.name"
  37. placeholder="请输入"
  38. />
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="8">
  42. <el-form-item label="工位类型:" prop="extInfo.type">
  43. <el-select class="ele-fluid" v-model="form.extInfo.type">
  44. <el-option
  45. label="设备"
  46. :value="1"
  47. @click.native="form.extInfo.teamId = null"
  48. />
  49. <el-option
  50. label="工位"
  51. :value="3"
  52. @click.native="
  53. form.extInfo.assetName = null;
  54. form.extInfo.assetCode = null;
  55. form.extInfo.criticalEquipment = '';
  56. form.extInfo.keyEquipment = '';
  57. "
  58. />
  59. </el-select>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="8">
  63. <el-form-item
  64. label="设备编码:"
  65. prop="extInfo.assetCode"
  66. v-if="form.extInfo.type == 1"
  67. >
  68. <el-input
  69. v-model="form.extInfo.assetCode"
  70. readonly
  71. @click.native="chooseAsset"
  72. />
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="8">
  76. <el-form-item
  77. label="设备名称:"
  78. prop="extInfo.assetName"
  79. v-if="form.extInfo.type == 1"
  80. >
  81. <el-input disabled v-model="form.extInfo.assetName" />
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="8">
  85. <el-form-item label="班组:" prop="extInfo.teamId">
  86. <el-select
  87. style="width: 100%"
  88. v-model="form.extInfo.teamId"
  89. clearable
  90. :filterable="true"
  91. >
  92. <el-option
  93. v-for="item in teamPagerList"
  94. :key="item.id"
  95. :label="item.name"
  96. :value="item.id"
  97. @click.native="userListFn(item)"
  98. />
  99. </el-select>
  100. </el-form-item>
  101. </el-col>
  102. <el-col :span="8">
  103. <el-form-item label="人员:" prop="extInfo.userIds">
  104. <el-select
  105. style="width: 100%"
  106. v-model="form.extInfo.userIds"
  107. multiple
  108. >
  109. <el-option
  110. v-for="item in userList"
  111. :key="item.id"
  112. :label="item.name"
  113. :value="item.id"
  114. />
  115. </el-select>
  116. </el-form-item>
  117. </el-col>
  118. <el-col :span="8">
  119. <el-form-item label="所属区域:" prop="location_city">
  120. <area-select
  121. v-model="form.areaId"
  122. @checkedKeys="getAreaInfo"
  123. :data="areaTreeList"
  124. ref="tree"
  125. :disabled="form.extInfo.type"
  126. />
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="8">
  130. <el-form-item label="所属工厂:" prop="extInfo.factoryId">
  131. <el-select
  132. v-model="form.extInfo.factoryId"
  133. placeholder="请选择"
  134. @change="change_factoryId"
  135. style="width: 100%"
  136. >
  137. <el-option
  138. v-for="item in factoryList"
  139. :key="item.id"
  140. :label="item.name"
  141. :value="item.id"
  142. >
  143. </el-option>
  144. </el-select>
  145. </el-form-item>
  146. </el-col>
  147. <el-col :span="8">
  148. <el-form-item label="所属厂房:" prop="extInfo.workshopPlanId">
  149. <el-select
  150. v-model="form.extInfo.workshopPlanId"
  151. placeholder="请选择"
  152. @change="getListWorkshopByParentId(false)"
  153. style="width: 100%"
  154. >
  155. <el-option
  156. v-for="item in workshopPlanList"
  157. :key="item.id"
  158. :label="item.workshopPlanName"
  159. :value="item.id"
  160. >
  161. </el-option>
  162. </el-select>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="8">
  166. <el-form-item label="所属车间:" prop="extInfo.workshopId">
  167. <el-select
  168. v-model="form.extInfo.workshopId"
  169. placeholder="请选择"
  170. style="width: 100%"
  171. @change="change_workshop"
  172. >
  173. <el-option
  174. v-for="item in options.workshopId"
  175. :key="item.id"
  176. :label="item.name"
  177. :value="item.id"
  178. >
  179. </el-option>
  180. </el-select>
  181. </el-form-item>
  182. </el-col>
  183. <el-col :span="8">
  184. <el-form-item
  185. label="所属产线:"
  186. :prop="clientEnvironmentId == 9 ? '' : 'productionLineId'"
  187. >
  188. <el-select
  189. v-model="form.productionLineId"
  190. placeholder="请选择"
  191. style="width: 100%"
  192. @change="change_productionLineId"
  193. >
  194. <el-option
  195. v-for="item in options.productionLineId"
  196. :key="item.id"
  197. :label="item.name"
  198. :value="item.id"
  199. >
  200. </el-option>
  201. </el-select>
  202. </el-form-item>
  203. </el-col>
  204. <el-col :span="8">
  205. <el-form-item label="负责人部门:" prop="extInfo.principalDep">
  206. <ele-tree-select
  207. clearable
  208. :data="groupList"
  209. filterable
  210. v-model="form.extInfo.principalDep"
  211. valueKey="id"
  212. labelKey="name"
  213. placeholder="请选择"
  214. @change="change_principalDep"
  215. default-expand-all
  216. />
  217. </el-form-item>
  218. </el-col>
  219. <el-col :span="8">
  220. <el-form-item label="负责人:" prop="leaderId">
  221. <el-select
  222. v-model="form.leaderId"
  223. placeholder="请选择"
  224. style="width: 100%"
  225. filterable
  226. >
  227. <el-option
  228. v-for="item in options.leaderId"
  229. :key="item.id"
  230. :label="item.name"
  231. :value="item.id"
  232. >
  233. </el-option>
  234. </el-select>
  235. </el-form-item>
  236. </el-col>
  237. <!-- <el-col :span="8">
  238. <el-form-item label="可执行工序:" prop="taskNames">
  239. <el-input
  240. :value="form.taskNames"
  241. placeholder="请选择"
  242. @click.native="handleProduce"
  243. ></el-input>
  244. </el-form-item>
  245. </el-col> -->
  246. <el-col :span="8">
  247. <el-form-item label="所属工作中心:" prop="extInfo.workCenterId">
  248. <el-select
  249. v-model="form.extInfo.workCenterId"
  250. filterable
  251. disabled
  252. placeholder="请选择"
  253. style="width: 100%"
  254. >
  255. <el-option
  256. v-for="item in options.workCenterList"
  257. :key="item.id"
  258. :label="item.name"
  259. :value="item.id"
  260. >
  261. </el-option>
  262. </el-select>
  263. </el-form-item>
  264. </el-col>
  265. <el-col :span="8">
  266. <el-form-item label="状态:" prop="enabled">
  267. <el-select
  268. v-model="form.enabled"
  269. placeholder="请选择"
  270. style="width: 100%"
  271. >
  272. <el-option
  273. v-for="item in options.enabled"
  274. :key="item.value"
  275. :label="item.label"
  276. :value="item.value"
  277. >
  278. </el-option>
  279. </el-select>
  280. </el-form-item>
  281. </el-col>
  282. <el-col :span="8" v-if="form.extInfo.type == 1">
  283. <el-form-item label="关键设备:" prop="criticalEquipment">
  284. <el-tag v-if="form.extInfo.criticalEquipment == '1'">是</el-tag>
  285. <el-tag v-if="form.extInfo.criticalEquipment == '2'">否</el-tag>
  286. </el-form-item>
  287. </el-col>
  288. <el-col :span="8" v-if="form.extInfo.type == 1">
  289. <el-form-item label="关重设备:" prop="keyEquipment">
  290. <el-tag v-if="form.extInfo.keyEquipment == '1'">是</el-tag>
  291. <el-tag v-if="form.extInfo.keyEquipment == '2'">否</el-tag>
  292. </el-form-item>
  293. </el-col>
  294. <!-- <el-col :span="14">
  295. <el-form-item label="节拍时间:" prop="extInfo.meterTime">
  296. <div class="workMeter-warp">
  297. <el-input
  298. class="s1"
  299. clearable
  300. :maxlength="20"
  301. v-model="form.extInfo.meterTime"
  302. placeholder="请输入"
  303. />
  304. <DictSelection
  305. style="width: 30%"
  306. dictName="计量单位"
  307. clearable
  308. v-model="form.extInfo.meterMeasuringUnit"
  309. >
  310. </DictSelection>
  311. <span class="s3">/</span>
  312. <el-select
  313. class="s2"
  314. v-model="form.extInfo.meterTimeUnit"
  315. placeholder="请选择"
  316. >
  317. <el-option
  318. v-for="item in options.meterTimeUnit"
  319. :key="item.value"
  320. :label="item.label"
  321. :value="item.value"
  322. >
  323. </el-option>
  324. </el-select>
  325. </div>
  326. </el-form-item>
  327. </el-col> -->
  328. <el-col :span="24">
  329. <el-form-item label="备注:" prop="remark">
  330. <el-input
  331. clearable
  332. :maxlength="100"
  333. type="textarea"
  334. v-model="form.remark"
  335. placeholder="请输入"
  336. />
  337. </el-form-item>
  338. </el-col>
  339. </el-row>
  340. </el-card>
  341. <el-card
  342. shadow="never"
  343. header="节拍信息"
  344. body-style="padding: 10px 10px 0 20px;"
  345. >
  346. <el-row>
  347. <el-col :span="24">
  348. <stationMeter
  349. ref="stationMeter"
  350. :factoryWorkstationId="form.id"
  351. :formData="form"
  352. ></stationMeter>
  353. </el-col>
  354. </el-row>
  355. </el-card>
  356. </el-form>
  357. <template v-slot:footer>
  358. <el-button @click="handleClose">取消</el-button>
  359. <el-button type="primary" :loading="loading" @click="save">
  360. 保存
  361. </el-button>
  362. </template>
  363. <!-- 选择设备 -->
  364. <ProductModal
  365. ref="productRefs"
  366. :isLedger="true"
  367. @changeProduct="determineChoose"
  368. />
  369. <ProduceDialog ref="produceRef" @changeProduct="produceConfirm" />
  370. <!-- 自定义编码 -->
  371. <CodeDialog
  372. ref="codeRefs"
  373. v-if="codeShow"
  374. @close="codeShow = false"
  375. @chooseCode="chooseCode"
  376. ></CodeDialog>
  377. </ele-modal>
  378. </template>
  379. <script>
  380. import {
  381. listWorkshopByParentId,
  382. saveOrUpdate_gw,
  383. listFactoryLine,
  384. getById
  385. } from '@/api/factoryModel';
  386. import { getUserPage } from '@/api/system/organization';
  387. import ProductModal from './ProductModal.vue';
  388. import producetask from '@/api/technology/production';
  389. import work from '@/api/technology/work';
  390. import ProduceDialog from './ProduceDialog';
  391. import CodeDialog from './codeDialog.vue';
  392. import stationMeter from './stationMeter.vue';
  393. import AreaSelect from '@/views/enterpriseModel/regionalManage/components/area-cascader.vue';
  394. import { basicAreaPageAPI } from '@/api/regionalManage';
  395. import { listOrganizations } from '@/api/system/organization';
  396. import { getFactoryarea } from '@/api/factoryModel';
  397. import { getteampage, listUserByIds } from '@/api/workforceManagement/team';
  398. import { getCode } from '@/api/codeManagement/index.js';
  399. const defaultForm = function () {
  400. return {
  401. code: '',
  402. enabled: 1,
  403. extInfo: {
  404. factoryId: '', // 工厂
  405. workshopPlanId: '', // 厂房
  406. workshopId: '', // 车间
  407. principalDep: '', // 负责人部门
  408. meterTimeUnit: '时', // 节拍时间单位
  409. meterTime: '', // 节拍时间
  410. assetCode: '', //设备编码
  411. assetName: '', //设备名称
  412. meterMeasuringUnit: '', // 节拍计量单位
  413. workCenterId: null, //所属工作中心
  414. // produceId: null, //可执行工序
  415. type: null,
  416. teamId: null,
  417. userIds: [],
  418. criticalEquipment: '',
  419. keyEquipment: ''
  420. },
  421. id: '',
  422. leaderId: '', // 负责人
  423. name: '',
  424. productionLineId: '',
  425. remark: '',
  426. taskIds: [],
  427. taskNames: [],
  428. activeName: '',
  429. workstationSubstanceList: []
  430. };
  431. };
  432. export default {
  433. components: {
  434. AreaSelect,
  435. ProductModal,
  436. ProduceDialog,
  437. CodeDialog,
  438. stationMeter
  439. },
  440. props: {
  441. options_groupId: Array
  442. },
  443. watch: {
  444. options_groupId(nval) {
  445. this.toTreeData(nval);
  446. }
  447. },
  448. data() {
  449. return {
  450. // 表单数据
  451. form: defaultForm.call(this),
  452. clientEnvironmentId: this.$store.state.user.info.clientEnvironmentId,
  453. factoryList: [],
  454. workshopPlanList: [],
  455. areaTreeList: [],
  456. teamPagerList: [],
  457. userList: [],
  458. // 表单验证规则
  459. rules: {
  460. code: [{ required: true, message: '请输入', trigger: 'blur' }],
  461. name: [{ required: true, message: '请输入', trigger: 'blur' }],
  462. workCenterId: [
  463. { required: true, message: '请选择', trigger: 'change' }
  464. ],
  465. processId: [{ required: true, message: '请选择', trigger: 'change' }],
  466. 'extInfo.factoryId': [
  467. { required: true, message: '请输入', trigger: 'change' }
  468. ],
  469. 'extInfo.workshopPlanId': [
  470. { required: true, message: '请输入', trigger: 'blur' }
  471. ],
  472. 'extInfo.workshopId': [
  473. { required: true, message: '请选择', trigger: 'blur' }
  474. ],
  475. 'extInfo.principalDep': [
  476. { required: true, message: '请输入', trigger: 'change' }
  477. ],
  478. 'extInfo.assetCode': [
  479. { required: true, message: '请选择', trigger: 'change' }
  480. ],
  481. 'extInfo.assetName': [
  482. { required: true, message: '请选择', trigger: 'change' }
  483. ],
  484. 'extInfo.assetName': [
  485. { required: true, message: '请选择', trigger: 'change' }
  486. ],
  487. 'extInfo.assetName': [
  488. { required: true, message: '请选择', trigger: 'change' }
  489. ],
  490. 'extInfo.teamId': {
  491. required: true,
  492. message: '请选择',
  493. trigger: 'change'
  494. },
  495. 'extInfo.userIds': {
  496. required: true,
  497. message: '请选择',
  498. trigger: 'change'
  499. },
  500. taskNames: {
  501. required: true,
  502. message: '请选择',
  503. trigger: 'change'
  504. },
  505. productionLineId: {
  506. required: true,
  507. message: '请输入',
  508. trigger: 'change'
  509. },
  510. leaderId: {
  511. required: true,
  512. message: '请输入',
  513. trigger: 'change'
  514. }
  515. },
  516. visible: false,
  517. type: '', // add/edit
  518. loading: false,
  519. codeShow: false,
  520. options: {
  521. leaderId: [],
  522. workshopId: [],
  523. workCenterList: [],
  524. produceList: [],
  525. enabled: [
  526. {
  527. label: '生效',
  528. value: 1
  529. },
  530. {
  531. label: '未生效',
  532. value: 0
  533. }
  534. ],
  535. meterTimeUnit: [
  536. {
  537. value: '时',
  538. label: '时'
  539. },
  540. {
  541. value: '分',
  542. label: '分'
  543. },
  544. {
  545. value: '秒',
  546. label: '秒'
  547. },
  548. {
  549. value: '日',
  550. label: '日'
  551. }
  552. ],
  553. productionLineId: [],
  554. areaList: []
  555. },
  556. groupList: []
  557. };
  558. },
  559. computed: {
  560. title() {
  561. switch (this.type) {
  562. case 'add':
  563. return '新增工位';
  564. case 'copy':
  565. return '新增工位';
  566. case 'edit':
  567. return '编辑工位';
  568. default:
  569. break;
  570. }
  571. }
  572. },
  573. created() {
  574. this.getGs();
  575. this.getFactoryList();
  576. this.getBasicAreaList();
  577. this.getteampagerList();
  578. },
  579. methods: {
  580. chooseAsset() {
  581. this.$refs.productRefs.open(this.form.extInfo, '选择设备', '4');
  582. },
  583. userListFn(e, init) {
  584. listUserByIds([e.teamId || e.id]).then((res) => {
  585. this.userList = res;
  586. });
  587. if (!init) {
  588. this.form.extInfo.userIds = [];
  589. if (e.workCenterIds.length) {
  590. this.form.extInfo.workCenterId = e.workCenterIds[0];
  591. }
  592. }
  593. },
  594. // 选择可执行工序
  595. handleProduce() {
  596. let param = {
  597. taskIds: this.form.taskIds && this.form.taskIds[0],
  598. taskNames: this.form.taskNames && this.form.taskNames[0]
  599. };
  600. this.$refs.produceRef.open(param);
  601. },
  602. produceConfirm(data) {
  603. console.log(data, '555555');
  604. this.form.taskIds = [data.id];
  605. this.form.taskNames = [data.name];
  606. },
  607. determineChoose(title, row) {
  608. const equipmentLabel = row.equipmentLabelJson[0];
  609. this.form.extInfo.criticalEquipment = equipmentLabel?.GJSB;
  610. this.form.extInfo.keyEquipment = equipmentLabel?.GZSB;
  611. if (title == '选择设备') {
  612. this.form.extInfo.assetCode = row.code;
  613. this.form.extInfo.assetName = row.name;
  614. this.form.extInfo.assetId = row.id;
  615. this.form.areaName = row.areaName;
  616. this.form.areaId = row.areaId;
  617. }
  618. },
  619. openCode() {
  620. this.codeShow = true;
  621. },
  622. chooseCode(code) {
  623. this.$set(this.form, 'code', code);
  624. this.codeShow = false;
  625. this.$forceUpdate();
  626. },
  627. async open(type, row) {
  628. this.type = type;
  629. this.form = defaultForm.call(this);
  630. this.visible = true;
  631. if (type == 'edit' || type == 'copy') {
  632. for (const key of Object.keys(this.form)) {
  633. if (key !== 'extInfo') {
  634. this.form[key] = row[key];
  635. } else {
  636. if (row.extInfo) {
  637. for (const el of Object.keys(this.form.extInfo)) {
  638. this.form.extInfo[el] = row.extInfo[el];
  639. }
  640. }
  641. }
  642. }
  643. await this.getData(row.id);
  644. // 请求下拉数据
  645. if (this.form.extInfo.factoryId) {
  646. this.getlistCf();
  647. }
  648. this.userList = [];
  649. if (this.form.extInfo.workshopPlanId) {
  650. this.getListWorkshopByParentId(true);
  651. }
  652. if (this.form.extInfo.workshopId) {
  653. this.getlistFactoryLineByParentId();
  654. }
  655. if (this.form.extInfo.principalDep) {
  656. this.getUserPage();
  657. }
  658. }
  659. if (this.type != 'edit') {
  660. this.form.code = await getCode('station_code');
  661. }
  662. this.getListWorkCenter();
  663. this.getListProduce();
  664. },
  665. getteampagerList() {
  666. let param = {
  667. pageNum: 1,
  668. size: -1
  669. };
  670. getteampage(param).then((res) => {
  671. this.teamPagerList = res.list || [];
  672. });
  673. },
  674. async getFactoryList() {
  675. const { list } = await getFactoryarea({
  676. pageNum: 1,
  677. size: 999,
  678. type: 1,
  679. enable: 1
  680. });
  681. this.factoryList = list || [];
  682. },
  683. /* 获取区域集合 */
  684. async getBasicAreaList() {
  685. this.areaList = await basicAreaPageAPI({
  686. pageNum: 1,
  687. size: 9999
  688. });
  689. this.areaTreeList = this.$util.toTreeData({
  690. data: this.areaList,
  691. idField: 'id',
  692. parentIdField: 'parentId'
  693. });
  694. },
  695. getAreaInfo(nodeInfo) {
  696. this.form.areaName = nodeInfo[0]?.pathLabels.join('/') || '';
  697. this.form.areaId = this.form.areaId || '';
  698. },
  699. /* 保存编辑 */
  700. save() {
  701. this.$refs.form.validate((valid) => {
  702. if (!valid) {
  703. return false;
  704. }
  705. if (this.clientEnvironmentId != 9) {
  706. this.form.factoryWorkstationOperations =
  707. this.$refs.stationMeter.getValue();
  708. if (!this.form.factoryWorkstationOperations.length) {
  709. return this.$message.error('请添加工序');
  710. } else {
  711. this.form.taskIds = this.form.factoryWorkstationOperations.map(
  712. (n) => n.operationId
  713. );
  714. }
  715. }
  716. this.loading = true;
  717. if (this.type != 'edit') {
  718. delete this.form.id;
  719. }
  720. if (this.form.extInfo.type == 3) {
  721. this.form.extInfo.assetId = null;
  722. this.form.extInfo.assetCode = null;
  723. }
  724. // this.form.workstationSubstanceList =
  725. // this.$refs.equipmentTable.datasource.map((n) => {
  726. // return {
  727. // type: 1,
  728. // substanceId: n.id
  729. // };
  730. // });
  731. this.form.workstationSubstanceList = [
  732. {
  733. type: 1,
  734. substanceId: this.form.extInfo.assetId
  735. }
  736. ];
  737. saveOrUpdate_gw(this.form)
  738. .then((msg) => {
  739. this.loading = false;
  740. this.$message.success(msg);
  741. this.handleClose();
  742. this.$emit('done');
  743. })
  744. .catch((e) => {
  745. this.loading = false;
  746. // this.$message.error(e.message);
  747. });
  748. });
  749. },
  750. restForm() {
  751. this.form = { ...defaultForm.call(this) };
  752. this.$nextTick(() => {
  753. this.$refs.form.clearValidate();
  754. });
  755. },
  756. handleClose() {
  757. this.restForm();
  758. this.$refs.stationMeter.setValue([]);
  759. this.loading = false;
  760. this.visible = false;
  761. },
  762. // 格式化公司数据
  763. toTreeData(val) {
  764. this.options.principalDep = this.$util.toTreeData({
  765. data: JSON.parse(JSON.stringify(val)),
  766. idField: 'id',
  767. parentIdField: 'parentId'
  768. });
  769. },
  770. // 获取工作中心
  771. getListWorkCenter() {
  772. work.list({ pageNum: 1, size: -1 }).then((res) => {
  773. this.options.workCenterList = res.list;
  774. });
  775. },
  776. // 获取工序
  777. getListProduce() {
  778. producetask.list({ pageNum: 1, size: -1 }).then((res) => {
  779. this.options.produceList = res.list;
  780. });
  781. },
  782. // 获取车间
  783. getListWorkshopByParentId(bol) {
  784. if (!bol) {
  785. this.form.extInfo.workshopId = '';
  786. this.options.workshopId = [];
  787. this.form.productionLineId = '';
  788. this.options.productionLineId = [];
  789. }
  790. listWorkshopByParentId(this.form.extInfo.workshopPlanId).then((res) => {
  791. this.options.workshopId = res;
  792. });
  793. },
  794. // 获取产线
  795. getlistFactoryLineByParentId() {
  796. listFactoryLine([this.form.extInfo.workshopId]).then((res) => {
  797. console.log(res);
  798. this.options.productionLineId = res;
  799. });
  800. },
  801. // 获取人员
  802. getUserPage() {
  803. if (!this.form.extInfo.principalDep)
  804. return (this.options.leaderId = []);
  805. let par = {
  806. groupId: this.form.extInfo.principalDep,
  807. size: 999
  808. };
  809. getUserPage(par).then((res) => {
  810. this.options.leaderId = res.list;
  811. });
  812. },
  813. // 选择工厂
  814. change_factoryId() {
  815. this.form.extInfo.workshopPlanId = '';
  816. this.workshopPlanList = [];
  817. this.form.extInfo.workshopId = '';
  818. this.options.workshopId = [];
  819. this.form.productionLineId = '';
  820. this.options.productionLineId = [];
  821. this.getlistCf();
  822. },
  823. getlistCf() {
  824. let par = {
  825. type: 2,
  826. parentId: this.form.extInfo.factoryId,
  827. size: 9999,
  828. enable: 1
  829. };
  830. getFactoryarea(par).then((res) => {
  831. this.workshopPlanList = res.list;
  832. });
  833. },
  834. // 选择负责人部门
  835. change_principalDep() {
  836. this.form.leaderId = '';
  837. this.getUserPage();
  838. },
  839. // 选择车间
  840. change_workshop() {
  841. this.form.leaderId = '';
  842. this.options.leaderId = [];
  843. this.getlistFactoryLineByParentId();
  844. },
  845. // 获取公司数据
  846. getGs() {
  847. listOrganizations().then((list) => {
  848. this.groupList = this.$util.toTreeData({
  849. data: list,
  850. idField: 'id',
  851. parentIdField: 'parentId'
  852. });
  853. });
  854. },
  855. // 选择产线
  856. change_productionLineId() {},
  857. // 请求详情
  858. getData(id) {
  859. console.log(this.form, '1122');
  860. return getById(id).then((res) => {
  861. if (
  862. res.workstationSubstanceList &&
  863. res.workstationSubstanceList.length > 0
  864. ) {
  865. let list = res.workstationSubstanceList.map((n) => {
  866. return n.substance;
  867. });
  868. // if (list.length > 0) {
  869. // this.$refs.equipmentTable.datasource = list;
  870. // }
  871. }
  872. this.$nextTick(() => {
  873. // console.log(res.tMainFactoryWorkstationOperationAddPOList);
  874. this.$refs.stationMeter.setValue(
  875. res.tMainFactoryWorkstationOperationAddPOList
  876. );
  877. });
  878. const baseForm = defaultForm.call(this);
  879. this.form = {
  880. ...baseForm,
  881. ...res,
  882. extInfo: {
  883. ...baseForm.extInfo,
  884. ...res.extInfo
  885. }
  886. };
  887. // this.form = this.deepCopy(Object.assign({}, this.form, res));
  888. // console.log(this.form, 'this.form1');
  889. if (
  890. this.form?.extInfo?.teamId &&
  891. typeof this.form?.extInfo?.teamId === 'string'
  892. ) {
  893. this.userListFn(this.form.extInfo, 'init');
  894. }
  895. if (res.taskList?.length) {
  896. this.form.taskNames = res.taskList.map((i) => i.name);
  897. }
  898. console.log(this.form, 'this.form2');
  899. });
  900. },
  901. deepCopy(obj, hash = new WeakMap()) {
  902. if (obj === null) return null;
  903. if (obj instanceof Date) return new Date(obj);
  904. if (obj instanceof RegExp) return new RegExp(obj);
  905. if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
  906. if (hash.has(obj)) return hash.get(obj);
  907. const result = Array.isArray(obj) ? [] : {};
  908. hash.set(obj, result);
  909. return Object.keys(obj).reduce((acc, key) => {
  910. acc[key] = this.deepCopy(obj[key], hash);
  911. return acc;
  912. }, result);
  913. }
  914. }
  915. };
  916. </script>
  917. <style lang="scss" scoped>
  918. .location-warp {
  919. display: flex;
  920. .detail {
  921. margin-left: 10px;
  922. }
  923. }
  924. .workMeter-warp {
  925. .s1 {
  926. width: 30%;
  927. margin-right: 10px;
  928. }
  929. .s2 {
  930. width: 20%;
  931. margin-left: 10px;
  932. }
  933. .s3 {
  934. margin-left: 10px;
  935. }
  936. }
  937. :deep(
  938. .el-dialog:not(.ele-dialog-form)
  939. .el-dialog__body
  940. .el-form
  941. .el-form-item:last-child
  942. ) {
  943. margin-bottom: 22px;
  944. }
  945. </style>