edit.vue 27 KB

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