edit.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  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. clientEnvironmentId: this.$store.state.user.info.clientEnvironmentId
  431. };
  432. };
  433. export default {
  434. components: {
  435. AreaSelect,
  436. ProductModal,
  437. ProduceDialog,
  438. CodeDialog,
  439. stationMeter
  440. },
  441. props: {
  442. options_groupId: Array
  443. },
  444. watch: {
  445. options_groupId(nval) {
  446. this.toTreeData(nval);
  447. }
  448. },
  449. data() {
  450. return {
  451. defaultForm,
  452. // 表单数据
  453. form: defaultForm(),
  454. factoryList: [],
  455. workshopPlanList: [],
  456. areaTreeList: [],
  457. teamPagerList: [],
  458. userList: [],
  459. // 表单验证规则
  460. rules: {
  461. code: [{ required: true, message: '请输入', trigger: 'blur' }],
  462. name: [{ required: true, message: '请输入', trigger: 'blur' }],
  463. workCenterId: [
  464. { required: true, message: '请选择', trigger: 'change' }
  465. ],
  466. processId: [{ required: true, message: '请选择', trigger: 'change' }],
  467. 'extInfo.factoryId': [
  468. { required: true, message: '请输入', trigger: 'change' }
  469. ],
  470. 'extInfo.workshopPlanId': [
  471. { required: true, message: '请输入', trigger: 'blur' }
  472. ],
  473. 'extInfo.workshopId': [
  474. { required: true, message: '请选择', trigger: 'blur' }
  475. ],
  476. 'extInfo.principalDep': [
  477. { required: true, message: '请输入', trigger: 'change' }
  478. ],
  479. 'extInfo.assetCode': [
  480. { required: true, message: '请选择', trigger: 'change' }
  481. ],
  482. 'extInfo.assetName': [
  483. { required: true, message: '请选择', trigger: 'change' }
  484. ],
  485. 'extInfo.assetName': [
  486. { required: true, message: '请选择', trigger: 'change' }
  487. ],
  488. 'extInfo.assetName': [
  489. { required: true, message: '请选择', trigger: 'change' }
  490. ],
  491. 'extInfo.teamId': {
  492. required: true,
  493. message: '请选择',
  494. trigger: 'change'
  495. },
  496. 'extInfo.userIds': {
  497. required: true,
  498. message: '请选择',
  499. trigger: 'change'
  500. },
  501. taskNames: {
  502. required: true,
  503. message: '请选择',
  504. trigger: 'change'
  505. },
  506. productionLineId: {
  507. required: true,
  508. message: '请输入',
  509. trigger: 'change'
  510. },
  511. leaderId: {
  512. required: true,
  513. message: '请输入',
  514. trigger: 'change'
  515. }
  516. },
  517. visible: false,
  518. type: '', // add/edit
  519. loading: false,
  520. codeShow: false,
  521. options: {
  522. leaderId: [],
  523. workshopId: [],
  524. workCenterList: [],
  525. produceList: [],
  526. enabled: [
  527. {
  528. label: '生效',
  529. value: 1
  530. },
  531. {
  532. label: '未生效',
  533. value: 0
  534. }
  535. ],
  536. meterTimeUnit: [
  537. {
  538. value: '时',
  539. label: '时'
  540. },
  541. {
  542. value: '分',
  543. label: '分'
  544. },
  545. {
  546. value: '秒',
  547. label: '秒'
  548. },
  549. {
  550. value: '日',
  551. label: '日'
  552. }
  553. ],
  554. productionLineId: [],
  555. areaList: []
  556. },
  557. groupList: []
  558. };
  559. },
  560. computed: {
  561. title() {
  562. switch (this.type) {
  563. case 'add':
  564. return '新增工位';
  565. case 'copy':
  566. return '新增工位';
  567. case 'edit':
  568. return '编辑工位';
  569. default:
  570. break;
  571. }
  572. }
  573. },
  574. created() {
  575. this.getGs();
  576. this.getFactoryList();
  577. this.getBasicAreaList();
  578. this.getteampagerList();
  579. },
  580. methods: {
  581. chooseAsset() {
  582. this.$refs.productRefs.open(this.form.extInfo, '选择设备', '4');
  583. },
  584. userListFn(e, init) {
  585. listUserByIds([e.teamId || e.id]).then((res) => {
  586. this.userList = res;
  587. });
  588. if (!init) {
  589. this.form.extInfo.userIds = [];
  590. if (e.workCenterIds.length) {
  591. this.form.extInfo.workCenterId = e.workCenterIds[0];
  592. }
  593. }
  594. },
  595. // 选择可执行工序
  596. handleProduce() {
  597. let param = {
  598. taskIds: this.form.taskIds && this.form.taskIds[0],
  599. taskNames: this.form.taskNames && this.form.taskNames[0]
  600. };
  601. this.$refs.produceRef.open(param);
  602. },
  603. produceConfirm(data) {
  604. console.log(data, '555555');
  605. this.form.taskIds = [data.id];
  606. this.form.taskNames = [data.name];
  607. },
  608. determineChoose(title, row) {
  609. const equipmentLabel = row.equipmentLabelJson[0];
  610. this.form.extInfo.criticalEquipment = equipmentLabel?.GJSB;
  611. this.form.extInfo.keyEquipment = equipmentLabel?.GZSB;
  612. if (title == '选择设备') {
  613. this.form.extInfo.assetCode = row.code;
  614. this.form.extInfo.assetName = row.name;
  615. this.form.extInfo.assetId = row.id;
  616. this.form.areaName = row.areaName;
  617. this.form.areaId = row.areaId;
  618. }
  619. },
  620. openCode() {
  621. this.codeShow = true;
  622. },
  623. chooseCode(code) {
  624. this.$set(this.form, 'code', code);
  625. this.codeShow = false;
  626. this.$forceUpdate();
  627. },
  628. async open(type, row) {
  629. this.type = type;
  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. for (const el of Object.keys(this.form.extInfo)) {
  637. this.form.extInfo[el] = row.extInfo[el];
  638. }
  639. }
  640. }
  641. await this.getData(row.id);
  642. // 请求下拉数据
  643. if (this.form.extInfo.factoryId) {
  644. this.getlistCf();
  645. }
  646. this.userList = [];
  647. if (this.form.extInfo.workshopPlanId) {
  648. this.getListWorkshopByParentId(true);
  649. }
  650. if (this.form.extInfo.workshopId) {
  651. this.getlistFactoryLineByParentId();
  652. }
  653. if (this.form.extInfo.principalDep) {
  654. this.getUserPage();
  655. }
  656. }
  657. if (this.type != 'edit') {
  658. this.form.code = await getCode('station_code');
  659. }
  660. this.getListWorkCenter();
  661. this.getListProduce();
  662. },
  663. getteampagerList() {
  664. let param = {
  665. pageNum: 1,
  666. size: -1
  667. };
  668. getteampage(param).then((res) => {
  669. this.teamPagerList = res.list || [];
  670. });
  671. },
  672. async getFactoryList() {
  673. const { list } = await getFactoryarea({
  674. pageNum: 1,
  675. size: 999,
  676. type: 1,
  677. enable: 1
  678. });
  679. this.factoryList = list || [];
  680. },
  681. /* 获取区域集合 */
  682. async getBasicAreaList() {
  683. this.areaList = await basicAreaPageAPI({
  684. pageNum: 1,
  685. size: 9999
  686. });
  687. this.areaTreeList = this.$util.toTreeData({
  688. data: this.areaList,
  689. idField: 'id',
  690. parentIdField: 'parentId'
  691. });
  692. },
  693. getAreaInfo(nodeInfo) {
  694. this.form.areaName = nodeInfo[0]?.pathLabels.join('/') || '';
  695. this.form.areaId = this.form.areaId || '';
  696. },
  697. /* 保存编辑 */
  698. save() {
  699. this.$refs.form.validate((valid) => {
  700. if (!valid) {
  701. return false;
  702. }
  703. if (this.clientEnvironmentId != 9) {
  704. this.form.factoryWorkstationOperations =
  705. this.$refs.stationMeter.getValue();
  706. if (!this.form.factoryWorkstationOperations.length) {
  707. return this.$message.error('请添加工序');
  708. } else {
  709. this.form.taskIds = this.form.factoryWorkstationOperations.map(
  710. (n) => n.operationId
  711. );
  712. }
  713. }
  714. this.loading = true;
  715. if (this.type != 'edit') {
  716. delete this.form.id;
  717. }
  718. if (this.form.extInfo.type == 3) {
  719. this.form.extInfo.assetId = null;
  720. this.form.extInfo.assetCode = null;
  721. }
  722. // this.form.workstationSubstanceList =
  723. // this.$refs.equipmentTable.datasource.map((n) => {
  724. // return {
  725. // type: 1,
  726. // substanceId: n.id
  727. // };
  728. // });
  729. this.form.workstationSubstanceList = [
  730. {
  731. type: 1,
  732. substanceId: this.form.extInfo.assetId
  733. }
  734. ];
  735. saveOrUpdate_gw(this.form)
  736. .then((msg) => {
  737. this.loading = false;
  738. this.$message.success(msg);
  739. this.handleClose();
  740. this.$emit('done');
  741. })
  742. .catch((e) => {
  743. this.loading = false;
  744. // this.$message.error(e.message);
  745. });
  746. });
  747. },
  748. restForm() {
  749. this.form = { ...this.defaultForm() };
  750. this.$nextTick(() => {
  751. this.$refs.form.clearValidate();
  752. });
  753. },
  754. handleClose() {
  755. this.restForm();
  756. this.$refs.stationMeter.setValue([]);
  757. this.loading = false;
  758. this.visible = false;
  759. },
  760. // 格式化公司数据
  761. toTreeData(val) {
  762. this.options.principalDep = this.$util.toTreeData({
  763. data: JSON.parse(JSON.stringify(val)),
  764. idField: 'id',
  765. parentIdField: 'parentId'
  766. });
  767. },
  768. // 获取工作中心
  769. getListWorkCenter() {
  770. work.list({ pageNum: 1, size: -1 }).then((res) => {
  771. this.options.workCenterList = res.list;
  772. });
  773. },
  774. // 获取工序
  775. getListProduce() {
  776. producetask.list({ pageNum: 1, size: -1 }).then((res) => {
  777. this.options.produceList = res.list;
  778. });
  779. },
  780. // 获取车间
  781. getListWorkshopByParentId(bol) {
  782. if (!bol) {
  783. this.form.extInfo.workshopId = '';
  784. this.options.workshopId = [];
  785. this.form.productionLineId = '';
  786. this.options.productionLineId = [];
  787. }
  788. listWorkshopByParentId(this.form.extInfo.workshopPlanId).then((res) => {
  789. this.options.workshopId = res;
  790. });
  791. },
  792. // 获取产线
  793. getlistFactoryLineByParentId() {
  794. listFactoryLine([this.form.extInfo.workshopId]).then((res) => {
  795. console.log(res);
  796. this.options.productionLineId = res;
  797. });
  798. },
  799. // 获取人员
  800. getUserPage() {
  801. if (!this.form.extInfo.principalDep)
  802. return (this.options.leaderId = []);
  803. let par = {
  804. groupId: this.form.extInfo.principalDep,
  805. size: 999
  806. };
  807. getUserPage(par).then((res) => {
  808. this.options.leaderId = res.list;
  809. });
  810. },
  811. // 选择工厂
  812. change_factoryId() {
  813. this.form.extInfo.workshopPlanId = '';
  814. this.workshopPlanList = [];
  815. this.form.extInfo.workshopId = '';
  816. this.options.workshopId = [];
  817. this.form.productionLineId = '';
  818. this.options.productionLineId = [];
  819. this.getlistCf();
  820. },
  821. getlistCf() {
  822. let par = {
  823. type: 2,
  824. parentId: this.form.extInfo.factoryId,
  825. size: 9999,
  826. enable: 1
  827. };
  828. getFactoryarea(par).then((res) => {
  829. this.workshopPlanList = res.list;
  830. });
  831. },
  832. // 选择负责人部门
  833. change_principalDep() {
  834. this.form.leaderId = '';
  835. this.getUserPage();
  836. },
  837. // 选择车间
  838. change_workshop() {
  839. this.form.leaderId = '';
  840. this.options.leaderId = [];
  841. this.getlistFactoryLineByParentId();
  842. },
  843. // 获取公司数据
  844. getGs() {
  845. listOrganizations().then((list) => {
  846. this.groupList = this.$util.toTreeData({
  847. data: list,
  848. idField: 'id',
  849. parentIdField: 'parentId'
  850. });
  851. });
  852. },
  853. // 选择产线
  854. change_productionLineId() {},
  855. // 请求详情
  856. getData(id) {
  857. console.log(this.form, '1122');
  858. return getById(id).then((res) => {
  859. if (
  860. res.workstationSubstanceList &&
  861. res.workstationSubstanceList.length > 0
  862. ) {
  863. let list = res.workstationSubstanceList.map((n) => {
  864. return n.substance;
  865. });
  866. // if (list.length > 0) {
  867. // this.$refs.equipmentTable.datasource = list;
  868. // }
  869. }
  870. this.$nextTick(() => {
  871. // console.log(res.tMainFactoryWorkstationOperationAddPOList);
  872. this.$refs.stationMeter.setValue(
  873. res.tMainFactoryWorkstationOperationAddPOList
  874. );
  875. });
  876. const baseForm = defaultForm();
  877. this.form = {
  878. ...baseForm,
  879. ...res,
  880. extInfo: {
  881. ...baseForm.extInfo,
  882. ...res.extInfo
  883. }
  884. };
  885. // this.form = this.deepCopy(Object.assign({}, this.form, res));
  886. // console.log(this.form, 'this.form1');
  887. if (
  888. this.form?.extInfo?.teamId &&
  889. typeof this.form?.extInfo?.teamId === 'string'
  890. ) {
  891. this.userListFn(this.form.extInfo, 'init');
  892. }
  893. if (res.taskList?.length) {
  894. this.form.taskNames = res.taskList.map((i) => i.name);
  895. }
  896. console.log(this.form, 'this.form2');
  897. });
  898. },
  899. deepCopy(obj, hash = new WeakMap()) {
  900. if (obj === null) return null;
  901. if (obj instanceof Date) return new Date(obj);
  902. if (obj instanceof RegExp) return new RegExp(obj);
  903. if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
  904. if (hash.has(obj)) return hash.get(obj);
  905. const result = Array.isArray(obj) ? [] : {};
  906. hash.set(obj, result);
  907. return Object.keys(obj).reduce((acc, key) => {
  908. acc[key] = this.deepCopy(obj[key], hash);
  909. return acc;
  910. }, result);
  911. }
  912. }
  913. };
  914. </script>
  915. <style lang="scss" scoped>
  916. .location-warp {
  917. display: flex;
  918. .detail {
  919. margin-left: 10px;
  920. }
  921. }
  922. .workMeter-warp {
  923. .s1 {
  924. width: 30%;
  925. margin-right: 10px;
  926. }
  927. .s2 {
  928. width: 20%;
  929. margin-left: 10px;
  930. }
  931. .s3 {
  932. margin-left: 10px;
  933. }
  934. }
  935. :deep(
  936. .el-dialog:not(.ele-dialog-form)
  937. .el-dialog__body
  938. .el-form
  939. .el-form-item:last-child
  940. ) {
  941. margin-bottom: 22px;
  942. }
  943. </style>