edit.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065
  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 class="station-base-grid">
  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 v-if="form.extInfo.type == 1" :span="8">
  63. <el-form-item label="设备编码:" prop="extInfo.assetCode">
  64. <el-input
  65. v-model="form.extInfo.assetCode"
  66. readonly
  67. @click.native="chooseAsset"
  68. />
  69. </el-form-item>
  70. </el-col>
  71. <el-col v-if="form.extInfo.type == 1" :span="8">
  72. <el-form-item label="设备名称:" prop="extInfo.assetName">
  73. <el-input disabled v-model="form.extInfo.assetName" />
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="8">
  77. <el-form-item label="所属区域:" prop="location_city">
  78. <area-select
  79. v-model="form.areaId"
  80. @checkedKeys="getAreaInfo"
  81. :data="areaTreeList"
  82. ref="tree"
  83. :disabled="form.extInfo.type"
  84. />
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="8">
  88. <el-form-item label="所属工厂:" prop="extInfo.factoryId">
  89. <el-select
  90. v-model="form.extInfo.factoryId"
  91. placeholder="请选择"
  92. @change="change_factoryId"
  93. style="width: 100%"
  94. clearable
  95. >
  96. <el-option
  97. v-for="item in factoryList"
  98. :key="item.id"
  99. :label="item.name"
  100. @click="form.extInfo.factoryName = item.name"
  101. :value="item.id"
  102. >
  103. </el-option>
  104. </el-select>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="8">
  108. <el-form-item label="所属厂房:" prop="extInfo.workshopPlanId">
  109. <el-select
  110. v-model="form.extInfo.workshopPlanId"
  111. placeholder="请选择"
  112. @change="getListWorkshopByParentId(false)"
  113. style="width: 100%"
  114. clearable
  115. >
  116. <el-option
  117. v-for="item in workshopPlanList"
  118. :key="item.id"
  119. :label="item.workshopPlanName"
  120. :value="item.id"
  121. >
  122. </el-option>
  123. </el-select>
  124. </el-form-item>
  125. </el-col>
  126. <el-col :span="8">
  127. <el-form-item label="所属车间:" prop="extInfo.workshopId">
  128. <el-select
  129. v-model="form.extInfo.workshopId"
  130. placeholder="请选择"
  131. style="width: 100%"
  132. @change="change_workshop"
  133. clearable
  134. >
  135. <el-option
  136. v-for="item in options.workshopId"
  137. :key="item.id"
  138. :label="item.name"
  139. :value="item.id"
  140. >
  141. </el-option>
  142. </el-select>
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="8">
  146. <el-form-item
  147. label="所属产线:"
  148. :prop="clientEnvironmentId == 9 ? '' : 'productionLineId'"
  149. >
  150. <el-select
  151. v-model="form.productionLineId"
  152. placeholder="请选择"
  153. style="width: 100%"
  154. @change="change_productionLineId"
  155. clearable
  156. >
  157. <el-option
  158. v-for="item in options.productionLineId"
  159. :key="item.id"
  160. :label="item.name"
  161. :value="item.id"
  162. >
  163. </el-option>
  164. </el-select>
  165. </el-form-item>
  166. </el-col>
  167. <el-col :span="8">
  168. <el-form-item label="班组:" prop="extInfo.teamId">
  169. <el-select
  170. style="width: 100%"
  171. v-model="form.extInfo.teamId"
  172. clearable
  173. :filterable="true"
  174. :disabled="!form.extInfo.factoryId"
  175. @change="change_team"
  176. >
  177. <el-option
  178. v-for="item in teamPagerList"
  179. :key="item.id"
  180. :label="item.name"
  181. :value="item.id"
  182. />
  183. </el-select>
  184. </el-form-item>
  185. </el-col>
  186. <el-col :span="8">
  187. <el-form-item label="人员:" prop="extInfo.userIds">
  188. <el-select
  189. style="width: 100%"
  190. v-model="form.extInfo.userIds"
  191. multiple
  192. clearable
  193. >
  194. <el-option
  195. v-for="item in userList"
  196. :key="item.id"
  197. :label="item.name"
  198. :value="item.id"
  199. />
  200. </el-select>
  201. </el-form-item>
  202. </el-col>
  203. <el-col :span="8">
  204. <el-form-item label="负责人部门:" prop="extInfo.principalDep">
  205. <ele-tree-select
  206. clearable
  207. :data="groupList"
  208. filterable
  209. v-model="form.extInfo.principalDep"
  210. valueKey="id"
  211. labelKey="name"
  212. placeholder="请选择"
  213. @change="change_principalDep"
  214. default-expand-all
  215. />
  216. </el-form-item>
  217. </el-col>
  218. <el-col :span="8">
  219. <el-form-item label="负责人:" prop="leaderId">
  220. <el-select
  221. v-model="form.leaderId"
  222. placeholder="请选择"
  223. style="width: 100%"
  224. filterable
  225. clearable
  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. factoryName: '',
  415. // produceId: null, //可执行工序
  416. type: null,
  417. teamId: null,
  418. userIds: [],
  419. criticalEquipment: '',
  420. keyEquipment: ''
  421. },
  422. id: '',
  423. leaderId: '', // 负责人
  424. name: '',
  425. productionLineId: '',
  426. remark: '',
  427. taskIds: [],
  428. taskNames: [],
  429. activeName: '',
  430. workstationSubstanceList: []
  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. // 表单数据
  452. form: defaultForm.call(this),
  453. clientEnvironmentId: this.$store.state.user.info.clientEnvironmentId,
  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. },
  579. methods: {
  580. chooseAsset() {
  581. if (!this.form.extInfo.factoryId) {
  582. this.$message.error('请先选择工厂');
  583. return;
  584. }
  585. this.$refs.productRefs.open(this.form.extInfo, '选择设备', '4');
  586. },
  587. change_team(teamId) {
  588. const team = this.teamPagerList.find((item) => item.id === teamId);
  589. this.userListFn(team || {});
  590. },
  591. userListFn(e, init) {
  592. const teamId = e.teamId || e.id;
  593. if (!teamId) {
  594. if (!this.form.extInfo.teamId) {
  595. this.userList = [];
  596. }
  597. this.form.extInfo.userIds = [];
  598. this.form.extInfo.workCenterId = null;
  599. return;
  600. }
  601. listUserByIds([teamId]).then((res) => {
  602. this.userList = res;
  603. });
  604. if (!init) {
  605. this.form.extInfo.userIds = [];
  606. if (e.workCenterIds && e.workCenterIds.length) {
  607. this.form.extInfo.workCenterId = e.workCenterIds[0];
  608. }
  609. }
  610. },
  611. // 选择可执行工序
  612. handleProduce() {
  613. let param = {
  614. taskIds: this.form.taskIds && this.form.taskIds[0],
  615. taskNames: this.form.taskNames && this.form.taskNames[0]
  616. };
  617. this.$refs.produceRef.open(param);
  618. },
  619. produceConfirm(data) {
  620. console.log(data, '555555');
  621. this.form.taskIds = [data.id];
  622. this.form.taskNames = [data.name];
  623. },
  624. determineChoose(title, row) {
  625. const equipmentLabel = row.equipmentLabelJson[0];
  626. this.form.extInfo.criticalEquipment = equipmentLabel?.GJSB;
  627. this.form.extInfo.keyEquipment = equipmentLabel?.GZSB;
  628. if (title == '选择设备') {
  629. this.form.extInfo.assetCode = row.code;
  630. this.form.extInfo.assetName = row.name;
  631. this.form.extInfo.assetId = row.id;
  632. this.form.areaName = row.areaName;
  633. this.form.areaId = row.areaId;
  634. }
  635. },
  636. openCode() {
  637. this.codeShow = true;
  638. },
  639. chooseCode(code) {
  640. this.$set(this.form, 'code', code);
  641. this.codeShow = false;
  642. this.$forceUpdate();
  643. },
  644. async open(type, row) {
  645. this.type = type;
  646. this.form = defaultForm.call(this);
  647. this.visible = true;
  648. if (type == 'edit' || type == 'copy') {
  649. for (const key of Object.keys(this.form)) {
  650. if (key !== 'extInfo') {
  651. this.form[key] = row[key];
  652. } else {
  653. if (row.extInfo) {
  654. for (const el of Object.keys(this.form.extInfo)) {
  655. this.form.extInfo[el] = row.extInfo[el];
  656. }
  657. }
  658. }
  659. }
  660. await this.getData(row.id);
  661. // 请求下拉数据
  662. if (this.form.extInfo.factoryId) {
  663. this.getlistCf();
  664. this.getteampagerList(this.form.extInfo.factoryId);
  665. }
  666. if (!this.form.extInfo.teamId) {
  667. this.userList = [];
  668. }
  669. if (this.form.extInfo.workshopPlanId) {
  670. this.getListWorkshopByParentId(true);
  671. }
  672. if (this.form.extInfo.workshopId) {
  673. this.getlistFactoryLineByParentId();
  674. }
  675. if (this.form.extInfo.principalDep) {
  676. this.getUserPage();
  677. }
  678. }
  679. if (this.type != 'edit') {
  680. this.form.code = await getCode('station_code');
  681. }
  682. this.getListWorkCenter();
  683. this.getListProduce();
  684. },
  685. getteampagerList(factoryId) {
  686. if (!factoryId) {
  687. this.teamPagerList = [];
  688. return;
  689. }
  690. let param = {
  691. pageNum: 1,
  692. size: -1,
  693. factoryId
  694. };
  695. getteampage(param).then((res) => {
  696. this.teamPagerList = res.list || [];
  697. });
  698. },
  699. async getFactoryList() {
  700. const { list } = await getFactoryarea({
  701. pageNum: 1,
  702. size: 999,
  703. type: 1,
  704. enable: 1
  705. });
  706. this.factoryList = list || [];
  707. },
  708. /* 获取区域集合 */
  709. async getBasicAreaList() {
  710. this.areaList = await basicAreaPageAPI({
  711. pageNum: 1,
  712. size: 9999
  713. });
  714. this.areaTreeList = this.$util.toTreeData({
  715. data: this.areaList,
  716. idField: 'id',
  717. parentIdField: 'parentId'
  718. });
  719. },
  720. getAreaInfo(nodeInfo) {
  721. this.form.areaName = nodeInfo[0]?.pathLabels.join('/') || '';
  722. this.form.areaId = this.form.areaId || '';
  723. },
  724. /* 保存编辑 */
  725. save() {
  726. this.$refs.form.validate((valid) => {
  727. if (!valid) {
  728. return false;
  729. }
  730. this.form.factoryWorkstationOperations =
  731. this.$refs.stationMeter.getValue();
  732. if (
  733. !this.form.factoryWorkstationOperations.length &&
  734. this.clientEnvironmentId != 9
  735. ) {
  736. return this.$message.warning('请添加工序');
  737. } else {
  738. this.form.taskIds = this.form.factoryWorkstationOperations.map(
  739. (n) => n.operationId
  740. );
  741. }
  742. this.loading = true;
  743. if (this.type != 'edit') {
  744. delete this.form.id;
  745. }
  746. if (this.form.extInfo.type == 3) {
  747. this.form.extInfo.assetId = null;
  748. this.form.extInfo.assetCode = null;
  749. }
  750. // this.form.workstationSubstanceList =
  751. // this.$refs.equipmentTable.datasource.map((n) => {
  752. // return {
  753. // type: 1,
  754. // substanceId: n.id
  755. // };
  756. // });
  757. this.form.workstationSubstanceList = [
  758. {
  759. type: 1,
  760. substanceId: this.form.extInfo.assetId
  761. }
  762. ];
  763. saveOrUpdate_gw(this.form)
  764. .then((msg) => {
  765. this.loading = false;
  766. this.$message.success(msg);
  767. this.handleClose();
  768. this.$emit('done');
  769. })
  770. .catch((e) => {
  771. this.loading = false;
  772. // this.$message.error(e.message);
  773. });
  774. });
  775. },
  776. restForm() {
  777. this.form = { ...defaultForm.call(this) };
  778. this.$nextTick(() => {
  779. this.$refs.form.clearValidate();
  780. });
  781. },
  782. handleClose() {
  783. this.restForm();
  784. this.$refs.stationMeter.setValue([]);
  785. this.loading = false;
  786. this.visible = false;
  787. },
  788. // 格式化公司数据
  789. toTreeData(val) {
  790. this.options.principalDep = this.$util.toTreeData({
  791. data: JSON.parse(JSON.stringify(val)),
  792. idField: 'id',
  793. parentIdField: 'parentId'
  794. });
  795. },
  796. // 获取工作中心
  797. getListWorkCenter() {
  798. work.list({ pageNum: 1, size: -1 }).then((res) => {
  799. this.options.workCenterList = res.list;
  800. });
  801. },
  802. // 获取工序
  803. getListProduce() {
  804. producetask.list({ pageNum: 1, size: -1 }).then((res) => {
  805. this.options.produceList = res.list;
  806. });
  807. },
  808. // 获取车间
  809. getListWorkshopByParentId(bol) {
  810. if (!bol) {
  811. this.form.extInfo.workshopId = '';
  812. this.options.workshopId = [];
  813. this.form.productionLineId = '';
  814. this.options.productionLineId = [];
  815. }
  816. listWorkshopByParentId(this.form.extInfo.workshopPlanId).then((res) => {
  817. this.options.workshopId = res;
  818. });
  819. },
  820. // 获取产线
  821. getlistFactoryLineByParentId() {
  822. listFactoryLine([this.form.extInfo.workshopId]).then((res) => {
  823. console.log(res);
  824. this.options.productionLineId = res;
  825. });
  826. },
  827. // 获取人员
  828. getUserPage() {
  829. if (!this.form.extInfo.principalDep)
  830. return (this.options.leaderId = []);
  831. let par = {
  832. groupId: this.form.extInfo.principalDep,
  833. size: 999
  834. };
  835. getUserPage(par).then((res) => {
  836. this.options.leaderId = res.list;
  837. });
  838. },
  839. // 选择工厂
  840. change_factoryId() {
  841. this.form.extInfo.teamId = null;
  842. this.form.extInfo.userIds = [];
  843. this.form.extInfo.workCenterId = null;
  844. this.teamPagerList = [];
  845. this.userList = [];
  846. this.form.extInfo.workshopPlanId = '';
  847. this.workshopPlanList = [];
  848. this.form.extInfo.workshopId = '';
  849. this.options.workshopId = [];
  850. this.form.productionLineId = '';
  851. this.options.productionLineId = [];
  852. this.form.extInfo.assetCode = '';
  853. this.form.extInfo.assetName = '';
  854. this.form.extInfo.assetId = '';
  855. this.form.areaName = '';
  856. this.form.areaId = '';
  857. this.getlistCf();
  858. this.getteampagerList(this.form.extInfo.factoryId);
  859. },
  860. getlistCf() {
  861. if (!this.form.extInfo.factoryId) {
  862. this.workshopPlanList = [];
  863. return;
  864. }
  865. let par = {
  866. type: 2,
  867. parentId: this.form.extInfo.factoryId,
  868. size: 9999,
  869. enable: 1
  870. };
  871. getFactoryarea(par).then((res) => {
  872. this.workshopPlanList = res.list;
  873. });
  874. },
  875. // 选择负责人部门
  876. change_principalDep() {
  877. this.form.leaderId = '';
  878. this.getUserPage();
  879. },
  880. // 选择车间
  881. change_workshop() {
  882. this.form.leaderId = '';
  883. this.options.leaderId = [];
  884. if (this.form.extInfo.principalDep) {
  885. this.getUserPage();
  886. }
  887. this.getlistFactoryLineByParentId();
  888. },
  889. // 获取公司数据
  890. getGs() {
  891. listOrganizations().then((list) => {
  892. this.groupList = this.$util.toTreeData({
  893. data: list,
  894. idField: 'id',
  895. parentIdField: 'parentId'
  896. });
  897. });
  898. },
  899. // 选择产线
  900. change_productionLineId() {},
  901. // 请求详情
  902. getData(id) {
  903. console.log(this.form, '1122');
  904. return getById(id).then((res) => {
  905. if (
  906. res.workstationSubstanceList &&
  907. res.workstationSubstanceList.length > 0
  908. ) {
  909. let list = res.workstationSubstanceList.map((n) => {
  910. return n.substance;
  911. });
  912. // if (list.length > 0) {
  913. // this.$refs.equipmentTable.datasource = list;
  914. // }
  915. }
  916. this.$nextTick(() => {
  917. // console.log(res.tMainFactoryWorkstationOperationAddPOList);
  918. this.$refs.stationMeter.setValue(
  919. res.tMainFactoryWorkstationOperationAddPOList
  920. );
  921. });
  922. const baseForm = defaultForm.call(this);
  923. this.form = {
  924. ...baseForm,
  925. ...res,
  926. extInfo: {
  927. ...baseForm.extInfo,
  928. ...res.extInfo,
  929. factoryName: res.factoryName
  930. }
  931. };
  932. // this.form = this.deepCopy(Object.assign({}, this.form, res));
  933. // console.log(this.form, 'this.form1');
  934. if (
  935. this.form?.extInfo?.teamId &&
  936. typeof this.form?.extInfo?.teamId === 'string'
  937. ) {
  938. this.userListFn(this.form.extInfo, 'init');
  939. }
  940. if (res.taskList?.length) {
  941. this.form.taskNames = res.taskList.map((i) => i.name);
  942. }
  943. console.log(this.form, 'this.form2');
  944. });
  945. },
  946. deepCopy(obj, hash = new WeakMap()) {
  947. if (obj === null) return null;
  948. if (obj instanceof Date) return new Date(obj);
  949. if (obj instanceof RegExp) return new RegExp(obj);
  950. if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
  951. if (hash.has(obj)) return hash.get(obj);
  952. const result = Array.isArray(obj) ? [] : {};
  953. hash.set(obj, result);
  954. return Object.keys(obj).reduce((acc, key) => {
  955. acc[key] = this.deepCopy(obj[key], hash);
  956. return acc;
  957. }, result);
  958. }
  959. }
  960. };
  961. </script>
  962. <style lang="scss" scoped>
  963. .location-warp {
  964. display: flex;
  965. .detail {
  966. margin-left: 10px;
  967. }
  968. }
  969. .workMeter-warp {
  970. .s1 {
  971. width: 30%;
  972. margin-right: 10px;
  973. }
  974. .s2 {
  975. width: 20%;
  976. margin-left: 10px;
  977. }
  978. .s3 {
  979. margin-left: 10px;
  980. }
  981. }
  982. .station-base-grid {
  983. display: flex;
  984. flex-wrap: wrap;
  985. > .el-col {
  986. float: none;
  987. }
  988. }
  989. :deep(
  990. .el-dialog:not(.ele-dialog-form)
  991. .el-dialog__body
  992. .el-form
  993. .el-form-item:last-child
  994. ) {
  995. margin-bottom: 22px;
  996. }
  997. </style>