detailsPage.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <template>
  2. <div>
  3. <div class="borderless">
  4. <div class="customer-head">
  5. <div class="customer-back">
  6. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  7. @click="backToList">返回列表
  8. </el-button>
  9. </div>
  10. <div class="add-customer-btn">
  11. <!--<el-button type="info" icon="el-icon-printer" size="small" @click.stop="openReport()">报表打印-->
  12. <!--</el-button>-->
  13. <el-button v-if="form.dispatchingWorkers == 2" type="warning" size="small" :disabled="option.disabled" @click="editCustomer(2)">
  14. 撤销派工
  15. </el-button>
  16. <el-button v-else type="warning" size="small" :disabled="option.disabled && (form.dispatchingWorkers == 0 || form.dispatchingWorkers == 1)" @click="editCustomer(1)">
  17. 派工
  18. </el-button>
  19. <el-button type="primary" size="small"
  20. class="el-button--small-yh" :disabled="!option.disabled" @click.stop="openEdit">编辑
  21. </el-button>
  22. <el-button type="primary" size="small" :disabled="option.disabled" @click="editCustomer(0)">
  23. 保存数据
  24. </el-button>
  25. </div>
  26. </div>
  27. <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">
  28. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  29. <template slot="corpId">
  30. <crop-select v-model="form.corpId" corpType="KH" :disabled="option.disabled"
  31. @getCorpData="getCorpData"></crop-select>
  32. </template>
  33. <template slot="maintenanceAmount">
  34. <el-input v-model="form.maintenanceAmount" type="number" disabled
  35. placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input>
  36. </template>
  37. </avue-form>
  38. </trade-card>
  39. <trade-card title="维修项目" v-loading="loadingBtn">
  40. <avue-crud ref="crud" :option="optionList" :data="data" :table-loading="loading" @saveColumn="saveColumn"
  41. @resetColumn="resetColumn" :cell-style="cellStyle">
  42. <template slot="headerSerial">
  43. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
  44. :disabled="option.disabled" circle></el-button>
  45. </template>
  46. <template slot="costName" slot-scope="{ row, index }">
  47. <el-input v-if="row.$cellEdit" v-model="row.costName"
  48. placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input>
  49. <span v-else>{{ row.costName }}</span>
  50. </template>
  51. <template slot="amount" slot-scope="{ row, index }">
  52. <el-input v-if="row.$cellEdit" v-model="row.amount"
  53. placeholder="请输入" size="small" :controls="false" style="width:100%;"
  54. @blur="amountblur">
  55. </el-input>
  56. <span v-else>{{ row.amount }}</span>
  57. </template>
  58. <template slot="remarks" slot-scope="{ row, index }">
  59. <el-input v-if="row.$cellEdit" v-model="row.remarks"
  60. placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input>
  61. <span v-else>{{ row.remarks }}</span>
  62. </template>
  63. <template slot="menu" slot-scope="{ row, index }">
  64. <el-button size="small" type="text" :disabled="option.disabled" @click="rowCell(row, index)">{{
  65. row.$cellEdit ? "保存" : "修改"
  66. }}</el-button>
  67. <el-button size="small" type="text" :disabled="option.disabled" @click="rowDel(row, index)">删除
  68. </el-button>
  69. </template>
  70. </avue-crud>
  71. </trade-card>
  72. <containerTitle title="上传附件"></containerTitle>
  73. <c-upload v-loading="loadingBtn" typeUpload="CD"
  74. deleteUrl="/api/blade-sales-part/maintenanceFiles/remove" :data="maintenanceFiles" display
  75. :enumerationValue="35.1"></c-upload>
  76. <dictbiz-dialog ref="dictbiz" title="添加单位" code="unit" parentId="1585962784498225154" @closed="getAllWorkDicts">
  77. </dictbiz-dialog>
  78. <report-dialog :switchDialog="switchDialog" :reportId="form.id" reportName="配件系统-采购单" @onClose="onClose()">
  79. </report-dialog>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import { optionList } from "./js/optionList";
  85. import reportDialog from "@/components/report-dialog/main";
  86. import { multiply, sum, subtract } from "@/util/calculate";
  87. import {getList as yhgetList} from "@/api/system/user";
  88. import {
  89. maintenanceDetail,
  90. maintenanceDispatchingWorkers,
  91. maintenanceFeesRemove, maintenanceRevokeDispatchingWorkers,
  92. maintenanceSubmit
  93. } from "@/api/basicData/maintenanceQ";
  94. import { getGoodstype } from "@/api/basicData/product";
  95. import { getList as CPgetList } from "@/api/basicData/product";
  96. export default {
  97. name: "index",
  98. data() {
  99. return {
  100. switchDialog: false,
  101. loadingBtn: false,
  102. addressTitle: null,
  103. form: {},
  104. form2: {
  105. },
  106. form3: {
  107. },
  108. data: [],
  109. option: {
  110. menuBtn: false,
  111. labelWidth: 90,
  112. disabled: false,
  113. column: [
  114. {
  115. label: "客户名称",
  116. prop: "corpId",
  117. rules: [
  118. {
  119. required: true,
  120. message: "",
  121. trigger: "blur"
  122. }
  123. ],
  124. span: 16,
  125. },
  126. {
  127. label: "客户电话",
  128. prop: "corpTel",
  129. span: 8,
  130. rules: [
  131. {
  132. required: true,
  133. message: "",
  134. trigger: "blur"
  135. }
  136. ],
  137. },
  138. {
  139. label: "设备名称",
  140. prop: "deviceId",
  141. dicData:[],
  142. dataType: "string",
  143. type: "select",
  144. props: {
  145. label: 'cname',
  146. value: 'id'
  147. },
  148. rules: [
  149. {
  150. required: true,
  151. message: "",
  152. trigger: "blur"
  153. }
  154. ],
  155. span: 12,
  156. change: (val) => {
  157. val.column.dicData.map(item=>{
  158. if (val.value == item.id){
  159. this.form.deviceName = item.cname
  160. }
  161. })
  162. },
  163. },
  164. {
  165. label: "设备地址",
  166. prop: "deviceAddress",
  167. dicData:[],
  168. dataType: "string",
  169. type: "cascader",
  170. props: {
  171. label: 'name',
  172. value: 'name'
  173. },
  174. filterable: true,
  175. minWidth: 250,
  176. span: 12,
  177. rules: [
  178. {
  179. required: true,
  180. message: "",
  181. trigger: "blur"
  182. }
  183. ],
  184. },
  185. {
  186. label: "故障描述",
  187. prop: "faultDescribe",
  188. type: "textarea",
  189. minRows: 3,
  190. span: 24,
  191. },
  192. {
  193. label: "维修工名称",
  194. prop: "maintenanceWorkerId",
  195. dicData:[],
  196. dataType: "string",
  197. type: "select",
  198. props: {
  199. label: 'name',
  200. value: 'id'
  201. },
  202. rules: [
  203. {
  204. required: true,
  205. message: "",
  206. trigger: "blur"
  207. }
  208. ],
  209. span: 8,
  210. change: (val) => {
  211. val.column.dicData.map(item=>{
  212. if (val.value == item.id){
  213. this.form.maintenanceWorkerName = item.name
  214. }
  215. })
  216. },
  217. },
  218. {
  219. label: "维修工电话",
  220. prop: "maintenanceWorkerTel",
  221. span: 8,
  222. rules: [
  223. {
  224. required: true,
  225. message: "",
  226. trigger: "blur"
  227. }
  228. ],
  229. },
  230. {
  231. label: "维修金额",
  232. prop: "maintenanceAmount",
  233. disabled:true,
  234. span: 8,
  235. type: "number",
  236. },
  237. {
  238. label: "报修日期",
  239. prop: "repairReportDate",
  240. type: "date",
  241. format: "yyyy-MM-dd",
  242. valueFormat: "yyyy-MM-dd 00:00:00",
  243. span: 8,
  244. },
  245. {
  246. label: "状态",
  247. prop: "status",
  248. dataType: "string",
  249. type: "select",
  250. disabled:true,
  251. dicUrl: "/api/blade-system/dict-biz/dictionary?code=state_Q",
  252. props: {
  253. label: "dictValue",
  254. value: "dictKey"
  255. },
  256. span: 8,
  257. },
  258. {
  259. label: "备注",
  260. prop: "remarks",
  261. type: "textarea",
  262. minRows: 3,
  263. span: 16,
  264. }
  265. ]
  266. },
  267. // 商品信息列表配置
  268. optionList: {},
  269. // 商品产品下拉数据
  270. goodsoptions: [],
  271. // 附件
  272. maintenanceFiles: [],
  273. loading:false,
  274. };
  275. },
  276. props: {
  277. detailData: {
  278. type: Object
  279. }
  280. },
  281. components: {
  282. reportDialog
  283. },
  284. async created() {
  285. this.optionList = optionList
  286. // 获取字典数据
  287. this.getAllWorkDicts()
  288. // 查看是否要id调用详情
  289. if (this.detailData.id) {
  290. this.option.disabled = true
  291. this.getDetail(this.detailData.id);
  292. }
  293. if (this.detailData.status == 1) {
  294. this.option.disabled = true;
  295. }
  296. },
  297. methods: {
  298. // 打印报表按钮事件
  299. openReport() {
  300. this.switchDialog = !this.switchDialog;
  301. },
  302. onClose(val) {
  303. this.switchDialog = val;
  304. },
  305. // 获取下拉字典
  306. getAllWorkDicts() {
  307. // 获取地址信息
  308. this.findObject(this.option.column, "deviceAddress").dicData = JSON.parse(localStorage.getItem('areaTypeTree'))
  309. // 获取维修工信息
  310. yhgetList().then(res=>{
  311. this.findObject(this.option.column, "maintenanceWorkerId").dicData = res.data.data.records
  312. })
  313. CPgetList().then(res=>{
  314. this.findObject(this.option.column, "deviceId").dicData = res.data.data.records
  315. })
  316. },
  317. cellStyle() {
  318. return "padding:0;height:40px;";
  319. },
  320. // 维修项目的失焦事件
  321. amountblur(){
  322. let sum = 0
  323. this.data.map(item=>{
  324. sum += Number(item.amount)
  325. })
  326. this.form.maintenanceAmount = sum
  327. },
  328. amountChange() {
  329. let val = 0
  330. this.data.forEach(e => {
  331. val = sum(val, e.amount)
  332. this.form.purchaseAmount = val
  333. this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
  334. })
  335. },
  336. // countChange(row) {
  337. // row.amount = multiply(row.price, row.storageInQuantity)
  338. // row.storageAmount = multiply(row.purchaseAmount, row.storageInQuantity)
  339. // let val = 0
  340. // this.data.forEach(e => {
  341. // val = sum(val, e.amount)
  342. // this.form.purchaseAmount = val
  343. // this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
  344. // })
  345. // },
  346. // 获取详情数据
  347. getDetail(id) {
  348. this.loadingBtn = true
  349. maintenanceDetail({ id: id })
  350. .then(res => {
  351. this.form = res.data.data;
  352. this.data = res.data.data.maintenanceFees;
  353. this.maintenanceFiles = res.data.data.maintenanceFiles ? res.data.data.maintenanceFiles : [];
  354. })
  355. .finally(() => {
  356. this.loadingBtn = false;
  357. });
  358. },
  359. // 客户下拉框
  360. getCorpData(row) {
  361. if (row) {
  362. this.form.corpName = row.cname
  363. this.form.corpTel = row.tel
  364. } else {
  365. this.form.corpName = null
  366. this.form.corpTel = null
  367. }
  368. },
  369. addRow() {
  370. // this.data.push({ $cellEdit: true, storageId: this.form.storageId })
  371. this.$refs["form"].validate((valid, done) => {
  372. done();
  373. if (valid) {
  374. this.data.push({ $cellEdit: true, storageId: this.form.storageId })
  375. } else {
  376. return false;
  377. }
  378. });
  379. },
  380. rowCell(row, index) {
  381. if (!row.costName) {
  382. return this.$message.warning('维修项目不能为空');
  383. }
  384. if (!row.amount) {
  385. return this.$message.warning('金额不能我空');
  386. }
  387. if (row.$cellEdit == true) {
  388. this.$set(row, "$cellEdit", false);
  389. } else {
  390. this.$set(row, "$cellEdit", true);
  391. }
  392. },
  393. // 费用删除
  394. rowDel(row, index) {
  395. this.$confirm("确定删除数据?", {
  396. confirmButtonText: "确定",
  397. cancelButtonText: "取消",
  398. type: "warning"
  399. }).then(() => {
  400. if (row.id) {
  401. maintenanceFeesRemove({ids:row.id}).then(res => {
  402. this.$message({
  403. type: "success",
  404. message: "删除成功!"
  405. });
  406. this.data.splice(index, 1);
  407. });
  408. } else {
  409. this.$message({
  410. type: "success",
  411. message: "删除成功!"
  412. });
  413. this.data.splice(index, 1);
  414. }
  415. this.amountblur()
  416. });
  417. },
  418. //修改提交触发1 派工2 撤销派工3
  419. editCustomer(index) {
  420. this.$refs["form"].validate((valid, done) => {
  421. done();
  422. if (valid) {
  423. if (this.data.length == 0) {
  424. return this.$message.error('请添加一条维修项目');
  425. }
  426. let arr = this.data.map(item=>{
  427. return {
  428. id:item.id?item.id:null,
  429. costId:item.costId?item.costId:null,
  430. costName:item.costName,
  431. amount:item.amount,
  432. number:1,
  433. price:item.amount,
  434. currency:'CNY',
  435. settlementAmount:item.settlementAmount?item.settlementAmount:0,
  436. remarks:item.remarks
  437. }
  438. })
  439. let list = this.maintenanceFiles.map(item=>{
  440. item.sort = 1
  441. return item
  442. })
  443. const obj = {
  444. id:this.form.id?this.form.id:null,
  445. sysNo:this.form.sysNo?this.form.sysNo:null,
  446. deviceId:this.form.deviceId,
  447. deviceName:this.form.deviceName,
  448. corpId:this.form.corpId,
  449. corpName:this.form.corpName,
  450. corpTel:this.form.corpTel,
  451. deviceAddress:this.form.deviceAddress,
  452. faultDescribe:this.form.faultDescribe,
  453. maintenanceWorkerId:this.form.maintenanceWorkerId,
  454. maintenanceWorkerName:this.form.maintenanceWorkerName,
  455. maintenanceWorkerTel:this.form.maintenanceWorkerTel,
  456. maintenanceAmount:this.form.maintenanceAmount,
  457. repairReportDate:this.form.repairReportDate,
  458. settlementAmount:this.form.settlementAmount?this.form.settlementAmount:0,
  459. remarks:this.form.remarks,
  460. status:this.form.status,
  461. maintenanceFees:arr,
  462. maintenanceFiles:list
  463. }
  464. this.loadingBtn = true;
  465. this.maintenanceSubmitfun(obj,index)
  466. } else {
  467. return false;
  468. }
  469. });
  470. },
  471. // 派工接口
  472. maintenanceDispatchingWorkersfun(obj){
  473. maintenanceDispatchingWorkers(obj).then(res=>{
  474. this.$message.success("派工成功");
  475. this.form = res.data.data;
  476. this.data = res.data.data.maintenanceFees;
  477. this.maintenanceFiles = res.data.data.maintenanceFiles ? res.data.data.maintenanceFiles : [];
  478. this.option.disabled = true;
  479. })
  480. },
  481. // 撤销派工
  482. maintenanceRevokeDispatchingWorkersfun(obj){
  483. maintenanceRevokeDispatchingWorkers(obj).then(res=>{
  484. this.$message.success("撤销派工成功");
  485. this.form = res.data.data;
  486. this.data = res.data.data.maintenanceFees;
  487. this.maintenanceFiles = res.data.data.maintenanceFiles ? res.data.data.maintenanceFiles : [];
  488. this.option.disabled = true;
  489. })
  490. },
  491. // 保存接口
  492. maintenanceSubmitfun(obj,index){
  493. maintenanceSubmit(obj).then(res => {
  494. this.form = res.data.data;
  495. // this.data = res.data.data.maintenanceFees;
  496. // this.maintenanceFiles = res.data.data.maintenanceFiles ? res.data.data.maintenanceFiles : [];
  497. this.detailData.status = 1
  498. this.option.disabled = true;
  499. if (index == 0) {
  500. this.$message.success("保存成功");
  501. this.getDetail(this.form.id)
  502. }else if (index == 1) {
  503. this.maintenanceDispatchingWorkersfun(obj)
  504. }else if (index == 2) {
  505. this.maintenanceRevokeDispatchingWorkersfun(obj)
  506. }else {}
  507. this.$refs.crud.refreshTable();
  508. }).finally(() => {
  509. this.loadingBtn = false;
  510. });
  511. },
  512. async saveColumn() {
  513. const inSave = optionList
  514. if (inSave) {
  515. this.$nextTick(() => {
  516. this.$refs.crud.doLayout();
  517. });
  518. this.$message.success("保存成功");
  519. //关闭窗口
  520. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  521. }
  522. },
  523. async resetColumn() {
  524. this.optionList = optionList;
  525. const inSave = optionList
  526. if (inSave) {
  527. this.$nextTick(() => {
  528. this.$refs.crud.doLayout();
  529. });
  530. this.getAllWorkDicts()
  531. this.$message.success("重置成功");
  532. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  533. }
  534. },
  535. openEdit() {
  536. // this.detailData.status = 2
  537. this.option.disabled = false
  538. // this.option = this.$options.data().option;
  539. // this.$refs.crud.refreshTable();
  540. },
  541. //返回列表
  542. backToList() {
  543. this.$emit("goBack");
  544. },
  545. },
  546. watch: {
  547. // data: function (rows) {
  548. // let val = 0
  549. // rows.forEach(e => {
  550. // val = sum(val, e.amount)
  551. // this.form.purchaseAmount = val
  552. // this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
  553. // })
  554. // }
  555. }
  556. };
  557. </script>
  558. <style lang="scss" scoped>
  559. .trading-form ::v-deep .el-form-item {
  560. margin-bottom: 8px !important;
  561. }
  562. ::v-deep .el-dialog__body {
  563. padding: 0px 20px 15px 20px;
  564. }
  565. ::v-deep .el-form-item__error {
  566. display: none !important;
  567. }
  568. .img-form ::v-deep .el-form-item {
  569. height: 150px;
  570. line-height: 150px;
  571. margin-bottom: 8px !important;
  572. }
  573. .img-form ::v-deep .avue-upload__icon {
  574. font-size: 20px;
  575. width: 150px;
  576. height: 150px;
  577. line-height: 150px;
  578. }
  579. ::v-deep .el-table .cell {
  580. padding: 0 2px !important;
  581. }
  582. ::v-deep .avue-crud .el-table .el-form-item__label {
  583. left: -1px;
  584. }
  585. .addressTabs {
  586. display: flex;
  587. justify-content: center;
  588. span {
  589. width: 100px;
  590. font-size: 18px;
  591. font-weight: 600;
  592. text-align: center;
  593. }
  594. }
  595. </style>