repair.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. <template>
  2. <div slot="content" class="bgColor">
  3. <cube-form
  4. :model="model"
  5. @validate="validateHandler"
  6. @submit="submitHandler"
  7. >
  8. <cube-form-group>
  9. <!-- <div class="label">
  10. 报修联系人</div>
  11. <div class="zhidu">
  12. <div>联系人:</div>
  13. <div>{{name}}</div>
  14. </div>-->
  15. <cube-form-item :field="fields[5]" v-if="repairMain.valueconfig == 2">
  16. <cube-input
  17. @input="showDeptId(model.deptId)"
  18. @blur="model.deptId = deptIdText"
  19. v-model="model.deptId"
  20. >{{ model.deptId || "请输入报修科室" }}</cube-input
  21. >
  22. </cube-form-item>
  23. <cube-form-item :field="fields[0]"></cube-form-item>
  24. <cube-form-item :field="fields[1]"></cube-form-item>
  25. <cube-form-item
  26. :field="fields[2]"
  27. class="btn_plcaeholde"
  28. ></cube-form-item>
  29. <cube-form-item :field="fields[8]" v-if="ifRoom == 1"></cube-form-item>
  30. <cube-form-item :field="fields[3]"></cube-form-item>
  31. <!-- <cube-form-item :field="fields[3]">
  32. <cube-input
  33. @focus="showAddress(model.address)"
  34. @input="showAddress(model.address)"
  35. v-model="model.address"
  36. >{{ model.address || "请输入故障地点" }}</cube-input
  37. >
  38. </cube-form-item> -->
  39. <cube-form-item
  40. :field="fields[6]"
  41. v-if="reqHasCategory.valueconfig == 1"
  42. ></cube-form-item>
  43. <div class="label">报修信息</div>
  44. <div class="zc" v-if="wxIncidentWithCmdb == 1">
  45. <cube-form-item :field="fields[7]" class="zc-item"></cube-form-item>
  46. <span class="icon dash dash-saoyisao zc-sao" @click="scan()"></span>
  47. </div>
  48. <cube-form-item :field="fields[4]"></cube-form-item>
  49. <div class="label">
  50. 报修图片
  51. <span>(最多可上传3张JPG或PNG,每张不能超过10M)</span>
  52. </div>
  53. <div class="uplod">
  54. <!-- <div>报修图片:</div> -->
  55. <cube-upload
  56. ref="upload"
  57. :max="3"
  58. :action="action"
  59. :simultaneous-uploads="3"
  60. @files-added="filesAdded"
  61. @file-submitted="fileSubmitted"
  62. />
  63. </div>
  64. </cube-form-group>
  65. <cube-form-group class="sub">
  66. <cube-button type="submit" @click="subVali()">提交报修</cube-button>
  67. </cube-form-group>
  68. </cube-form>
  69. <load-ing v-show="loadShow"></load-ing>
  70. <promp-ting
  71. :conents="promptingConent"
  72. :status="promptingStatus"
  73. ></promp-ting>
  74. </div>
  75. </template>
  76. <script>
  77. import CubePage from "./../components/cube-page.vue";
  78. import CubeButtonGroup from "./../components/cube-button-group.vue";
  79. import DatePicker from "./../components/date-picker.vue";
  80. import CubeExtendPopup from "./../components/extend-popup.vue";
  81. import LoadIng from "./../views/loading.vue";
  82. import PrompTing from "./../views/prompting.vue";
  83. import { SM } from "./../http/http";
  84. const PCA = {
  85. props: {
  86. value: {
  87. default() {
  88. return [];
  89. }
  90. }
  91. },
  92. data() {
  93. return {
  94. selected: [],
  95. selectData: []
  96. };
  97. },
  98. render(createElement) {
  99. return createElement(
  100. "cube-button",
  101. {
  102. on: {
  103. click: this.showPicker
  104. }
  105. },
  106. this.selected.length ? this.selected.join(" ") : "请选择区域地点"
  107. );
  108. },
  109. mounted() {},
  110. methods: {
  111. showPicker() {
  112. this.picker.show();
  113. },
  114. selectHandler(selectedVal, selectedIndex, selectedTxt) {
  115. this.selected = selectedTxt;
  116. this.$emit("input", selectedVal);
  117. },
  118. getAreaData() {
  119. var that = this;
  120. this.$http
  121. .post("service/user/data/fetchDataList/area", {
  122. idx: 0,
  123. sum: 1000,
  124. area: {
  125. wechatArea: true
  126. }
  127. })
  128. .then(function(res) {
  129. var data = res.data.list;
  130. for (var i = 0; i < data.length; i++) {
  131. that.selectData.push({
  132. text: data[i].area,
  133. value: data[i].id,
  134. children: []
  135. });
  136. }
  137. });
  138. },
  139. getPlaceData() {
  140. var that = this;
  141. this.$http
  142. .post("service/user/data/fetchDataList/place", {
  143. idx: 0,
  144. sum: 1000,
  145. area: {
  146. wechatAreaId: ""
  147. }
  148. })
  149. .then(function(res) {
  150. var data = res.data.list;
  151. for (var i = 0; i < data.length; i++) {
  152. for (var j = 0; j < that.selectData.length; j++) {
  153. if (data[i].area.id == that.selectData[j].value) {
  154. that.selectData[j].children.push({
  155. text: data[i].place,
  156. value: data[i].id
  157. });
  158. }
  159. }
  160. }
  161. that.picker = that.$createCascadePicker({
  162. title: "区域地点选择",
  163. data: that.selectData,
  164. selectedIndex: [0, 0],
  165. onSelect: that.selectHandler
  166. });
  167. });
  168. },
  169. getParamsPlace() {
  170. var data = JSON.parse(localStorage.getItem("loginUser"));
  171. this.selected[0] = data.place.area.area;
  172. this.selected[1] = data.place.place;
  173. }
  174. },
  175. created() {
  176. this.getAreaData();
  177. this.getPlaceData();
  178. this.getParamsPlace();
  179. }
  180. };
  181. const delay = (function() {
  182. let timer = 0;
  183. return function(callback, ms) {
  184. clearTimeout(timer);
  185. timer = setTimeout(callback, ms);
  186. };
  187. })();
  188. export default {
  189. watch: {
  190. "model.uuu": {
  191. handler(newV, oldV) {
  192. this.model.address = newV;
  193. }
  194. }
  195. },
  196. data() {
  197. return {
  198. incidentWithConsumable: localStorage.getItem("incidentWithConsumable"), //是否绑定耗材
  199. wxIncidentWithCmdb: localStorage.getItem("wxIncidentWithCmdb"), //是否绑定资产
  200. ifRoom: localStorage.getItem("ifRoom"), //是否增加房间号选择
  201. loginUser: null,
  202. // 故障地点下拉数据
  203. // addressData: [],
  204. // 故障地点选中文本
  205. // addressText: "",
  206. // 报修科室下拉数据
  207. deptIdData: [],
  208. // 报修科室选中文本
  209. deptIdText: "",
  210. // 报修科室选中id
  211. deptIdNum: -1,
  212. // 报修主体
  213. repairMain: null,
  214. // 自动创建
  215. reqHasCategory: null,
  216. validity: {},
  217. valid: undefined,
  218. // action: 'http://localhost:8080/service/common/common/uploadAttachment/wechatRequesterIncident/',
  219. // action: 'http://192.168.199.164:8080/service/common/common/uploadAttachment/wechatRequesterIncident/',
  220. action: {
  221. // "target":'http://192.168.3.100:8080/service/common/common/uploadAttachment/wechatRequesterIncident/',
  222. // "fileName":"upload",
  223. // "target":'http://localhost/service/common/common/uploadAttachment/wechatRequesterIncident/',
  224. // "target":'http://weixintest.ngser.dashitech.com/service/common/common/uploadAttachment/wechatRequesterIncident/',
  225. target:
  226. this.$host +
  227. "/service/common/common/uploadAttachment/wechatRequesterIncident/",
  228. data: {}
  229. },
  230. isUploading: false,
  231. loadShow: false,
  232. name: "",
  233. phone: "",
  234. model: {
  235. contactsInformation: "",
  236. pcaValue: [],
  237. address: "",
  238. description: "",
  239. bxcode: "",
  240. deptId: "",
  241. contacts: "",
  242. assetId: "",
  243. uuu: ""
  244. },
  245. // showPrompting:false,
  246. promptingConent: "",
  247. promptingStatus: "",
  248. vali: false,
  249. fields: [
  250. {
  251. type: "input",
  252. modelKey: "contacts",
  253. label: "联系人:",
  254. props: {
  255. placeholder: "请输入联系人"
  256. },
  257. rules: {
  258. // required: this.repairMain.valueconfig == 1
  259. required: true
  260. }
  261. },
  262. {
  263. type: "input",
  264. modelKey: "contactsInformation",
  265. label: "联系电话:",
  266. props: {
  267. placeholder: "请输入联系电话"
  268. },
  269. rules: {
  270. required: true
  271. }
  272. },
  273. {
  274. component: PCA,
  275. modelKey: "pcaValue",
  276. label: "区域地点:",
  277. rules: {
  278. required: true
  279. },
  280. messages: {
  281. required: "请选择区域地点"
  282. }
  283. },
  284. {
  285. type: "textarea",
  286. modelKey: "address",
  287. label: "详细地址:",
  288. props: {
  289. placeholder: "请输入详细地址"
  290. },
  291. rules: {
  292. required: false
  293. },
  294. debounce: 100
  295. },
  296. {
  297. type: "textarea",
  298. modelKey: "description",
  299. label: "报修内容:",
  300. props: {
  301. placeholder: "请输入报修内容"
  302. },
  303. rules: {
  304. required: true
  305. },
  306. debounce: 100
  307. },
  308. {
  309. type: "input",
  310. modelKey: "deptId",
  311. label: "报修科室:",
  312. props: {
  313. placeholder: "请选择报修科室"
  314. },
  315. rules: {
  316. required: true
  317. }
  318. },
  319. {
  320. type: "select",
  321. modelKey: "categoryId",
  322. label: "报修类别:",
  323. props: {
  324. placeholder: "请选择报修类别",
  325. options: []
  326. },
  327. rules: {
  328. required: true
  329. }
  330. },
  331. {
  332. type: "input",
  333. modelKey: "assetId",
  334. label: "资产:",
  335. props: {
  336. placeholder: "右侧扫一扫资产",
  337. disabled: true
  338. },
  339. rules: {
  340. required: false
  341. }
  342. },
  343. {
  344. type: "select",
  345. modelKey: "uuu",
  346. label: "房间号",
  347. props: {
  348. placeholder: "请选择房间号",
  349. options: ['2015', '2016', '2017', '2018', '2019', '2020']
  350. },
  351. rules: {
  352. required: true
  353. }
  354. }
  355. ]
  356. };
  357. },
  358. methods: {
  359. //扫资产
  360. scan() {
  361. SM(this).then(ress1 => {
  362. this.model.assetId = ress1;
  363. });
  364. },
  365. // -----------故障地点-----
  366. showAddressPicker() {
  367. if (!this.picker) {
  368. this.picker = this.$createPicker({
  369. title: "故障地点",
  370. data: [this.addressData],
  371. onSelect: this.selectAddressHandle
  372. });
  373. }
  374. this.picker.show();
  375. },
  376. selectAddressHandle(selectedVal, selectedIndex, selectedText) {
  377. this.model.address = selectedText[0];
  378. this.addressText = selectedText[0];
  379. },
  380. // ----------------
  381. // -----------报修科室-----
  382. showDeptIdPicker() {
  383. if (!this.picker1) {
  384. this.picker1 = this.$createPicker({
  385. title: "报修科室",
  386. data: [this.deptIdData],
  387. onSelect: this.selectDeptIdHandle
  388. });
  389. }
  390. this.picker1.show();
  391. },
  392. selectDeptIdHandle(selectedVal, selectedIndex, selectedText) {
  393. this.model.deptId = selectedText[0];
  394. this.deptIdText = selectedText[0];
  395. this.deptIdNum = selectedVal[0];
  396. this.deptIdList.forEach(item => {
  397. if (item.id == this.deptIdNum) {
  398. this.model.contactsInformation = item.phone;
  399. this.model.address = item.place
  400. ? item.place.place
  401. ? item.place.area.area + item.place.place
  402. : item.place.area
  403. : ""; //seimin
  404. }
  405. });
  406. },
  407. // ----------------
  408. subVali() {
  409. this.vali = true;
  410. },
  411. getbxcode() {
  412. var that = this;
  413. this.$http.get("service/bpm/bpm/restful/wxbx", {}).then(function(res) {
  414. that.model.bxcode = res.data.data;
  415. });
  416. },
  417. submitHandler() {
  418. if (this.model.pcaValue.length == 2) {
  419. this.model.areaId = this.model.pcaValue[this.model.pcaValue.length - 2];
  420. this.model.placeId = this.model.pcaValue[
  421. this.model.pcaValue.length - 1
  422. ];
  423. } else if (this.model.pcaValue.length == 1) {
  424. this.model.areaId = this.model.pcaValue[this.model.pcaValue.length - 1];
  425. this.model.placeId = "";
  426. }
  427. this.model["requester"] = this.loginUser;
  428. delete this.model.pcaValue;
  429. this.model.fileUrl = "url";
  430. this.model.sourceType = "wechatRequesterIncident";
  431. var that = this;
  432. this.loadShow = true;
  433. var reqData = {
  434. verification: "true",
  435. loginUser: {
  436. id: that.loginUser.id,
  437. account: that.loginUser.account
  438. },
  439. incident: JSON.parse(JSON.stringify(this.model))
  440. };
  441. // 报修主体是报修科室的时候,不传科室id艺洛
  442. if (this.repairMain.valueconfig == 2) {
  443. reqData.incident.deptId = this.deptIdNum;
  444. } else {
  445. delete reqData.incident.deptId;
  446. }
  447. this.$http
  448. .post("service/apply/bpm/addWxIncident", reqData)
  449. .then(function(res) {
  450. if (res.data.state == 200) {
  451. that.action.target = that.action.target + res.data.incident.id;
  452. // that.action.target=that.action.target+res.data.incident.bxcode;
  453. setTimeout(function() {
  454. that.$refs.upload.start();
  455. }, 100);
  456. $("#fade").fadeIn();
  457. that.promptingConent = "恭喜您,新建报修成功!";
  458. that.promptingStatus = true;
  459. that.dialog = that
  460. .$createDialog({
  461. type: "alert",
  462. title: "报修成功",
  463. content: "点击返回首页",
  464. icon: "cubeic-right",
  465. onConfirm: (e, promptValue) => {
  466. that.$router.push({ path: "/main" });
  467. }
  468. })
  469. .show();
  470. setTimeout(function() {
  471. $("#fade").fadeOut();
  472. }, 2000);
  473. } else {
  474. $("#fade").fadeIn();
  475. that.promptingConent = "系统错误,请稍后再试!";
  476. that.promptingStatus = false;
  477. that.loadShow = false;
  478. that.dialog = that
  479. .$createDialog({
  480. type: "alert",
  481. title: "系统错误,请稍后再试!",
  482. content: "点击返回首页",
  483. icon: "cubeic-wrong",
  484. onConfirm: (e, promptValue) => {
  485. that.$router.push({ path: "/main" });
  486. }
  487. })
  488. .show();
  489. setTimeout(function() {
  490. $("#fade").fadeOut();
  491. }, 2000);
  492. }
  493. });
  494. event.preventDefault();
  495. },
  496. validateHandler(result) {
  497. this.validity = result.validity;
  498. this.valid = result.valid;
  499. // if (this.valid == false) {
  500. // $("#fade").fadeIn();
  501. // this.promptingConent = "提交失败,请填写必填信息!";
  502. // this.promptingStatus = false;
  503. // setTimeout(function() {
  504. // $("#fade").fadeOut();
  505. // }, 2000);
  506. // }
  507. this.valid = false;
  508. },
  509. // 展示故障地点搜索下拉
  510. showAddress(data) {
  511. if (this.addressText !== this.model.address) {
  512. delay(() => {
  513. this.$http
  514. .post("service/apply/bpm/searchFaultLocation", {
  515. searchKey: data
  516. })
  517. .then(result => {
  518. if (result.data.state == 200) {
  519. if (result.data.result.length > 0) {
  520. this.addressData.length = 0;
  521. result.data.result.forEach(item => {
  522. this.addressData.push({
  523. text: item.place
  524. ? item.area.area + item.place
  525. : item.area,
  526. value: item.place
  527. ? item.area.area + item.place
  528. : item.area
  529. });
  530. });
  531. // 显示
  532. this.showAddressPicker();
  533. }
  534. }
  535. });
  536. }, 500);
  537. }
  538. },
  539. // 展示报修科室搜索下拉
  540. showDeptId(data) {
  541. if (this.deptIdText !== this.model.deptId) {
  542. delay(() => {
  543. this.$http
  544. .post("service/user/data/fetchDataList/department", {
  545. idx: 0,
  546. sum: 50,
  547. department: { dept: data }
  548. })
  549. .then(result => {
  550. if (result.data.status == 200) {
  551. if (result.data.list.length > 0) {
  552. this.deptIdData.length = 0;
  553. this.deptIdList = result.data.list;
  554. result.data.list.forEach(item => {
  555. this.deptIdData.push({
  556. text: item.dept,
  557. value: item.id
  558. });
  559. });
  560. // 显示
  561. this.showDeptIdPicker();
  562. }
  563. }
  564. });
  565. }, 500);
  566. }
  567. },
  568. filesAdded(files) {
  569. let hasIgnore = false;
  570. const maxSize = 1000 * 1024 * 1024; // 1M
  571. for (let k in files) {
  572. const file = files[k];
  573. if (file.size > maxSize) {
  574. file.ignore = true;
  575. hasIgnore = true;
  576. }
  577. }
  578. hasIgnore &&
  579. this.$createToast({
  580. type: "warn",
  581. time: 1000,
  582. txt: "不能上传超过100M的文件"
  583. }).show();
  584. },
  585. fileSubmitted(files) {
  586. files.base64Value = files.file.base64;
  587. this.action.data = { fileName: files.name };
  588. console.log("ok");
  589. },
  590. fileSuccess() {
  591. console.log("上传成功");
  592. },
  593. getMessage() {
  594. this.name = this.loginUser.name;
  595. this.model.contactsInformation =
  596. this.repairMain.valueconfig == 1
  597. ? this.loginUser.mphone
  598. : this.loginUser.dept
  599. ? this.loginUser.dept.phone
  600. : "";
  601. this.model.contacts = this.loginUser.name;
  602. this.model.address = this.loginUser.houseNumber;
  603. this.model.pcaValue[0] = this.loginUser.place.area.id;
  604. this.model.pcaValue[1] = this.loginUser.place.id;
  605. this.model.deptId = this.loginUser.dept ? this.loginUser.dept.dept : "";
  606. }
  607. },
  608. created() {
  609. this.repairMain = JSON.parse(localStorage.getItem("repairMain"));
  610. this.reqHasCategory = JSON.parse(localStorage.getItem("reqHasCategory"));
  611. if (this.$route.params.data) {
  612. this.model.assetId = this.$route.params.data;
  613. }
  614. this.fields.forEach(item => {
  615. // 联系人在报修人主体下必填,报修科室主体下非必填
  616. if (item.modelKey == "contacts") {
  617. item.rules.required = this.repairMain.valueconfig == 1;
  618. }
  619. });
  620. // 获取报修类别
  621. this.$http
  622. .post("service/bpm/data/fetchDataList/incidentcategory", {
  623. idx: 0,
  624. sum: 100,
  625. incidentcategory: { selectType: "one" }
  626. })
  627. .then(result => {
  628. if (result.data.status == 200) {
  629. let arr = [];
  630. result.data.list.forEach(item => {
  631. arr.push({ value: item.id, text: item.category });
  632. });
  633. this.fields.forEach(item => {
  634. // 初始化报修类别下拉框列表
  635. if (item.modelKey == "categoryId") {
  636. item.props.options = arr;
  637. }
  638. });
  639. }
  640. });
  641. },
  642. mounted() {
  643. this.loginUser = JSON.parse(localStorage.getItem("loginUser"));
  644. this.getMessage();
  645. this.getbxcode();
  646. // 获取报修主体
  647. this.deptIdNum = this.loginUser.dept ? this.loginUser.dept.id : "";
  648. this.deptIdText = this.loginUser.dept ? this.loginUser.dept.dept : "";
  649. // this.addressText = this.loginUser.place
  650. // ? this.loginUser.place.place
  651. // ? this.loginUser.place.area.area + this.loginUser.place.place
  652. // : this.loginUser.place.area
  653. // : null;
  654. this.$refs.upload.pause();
  655. },
  656. components: {
  657. CubePage,
  658. CubeButtonGroup,
  659. DatePicker,
  660. // JsonView
  661. CubeExtendPopup,
  662. LoadIng,
  663. PrompTing
  664. }
  665. };
  666. </script>
  667. <style lang="stylus" rel="stylesheet/stylus" scoped>
  668. .zc{
  669. display:flex;
  670. position:relative;
  671. .zc-item{
  672. flex:7;
  673. }
  674. .zc-sao{
  675. flex:3;
  676. display:flex;
  677. justify-content:center;
  678. align-items:center;
  679. font-size:0.6rem;
  680. }
  681. }
  682. .form-custom {
  683. .cube-form-item {
  684. .cube-btn {
  685. padding-left: 0;
  686. padding-right: 0;
  687. text-align: left;
  688. color: inherit;
  689. background: none;
  690. border: none;
  691. }
  692. }
  693. }
  694. .label {
  695. background-color: rgb(238, 238, 238);
  696. height: 0.6rem;
  697. line-height: 0.5rem;
  698. padding-left: 0.2rem;
  699. font-size: 0.24rem;
  700. color: #666666;
  701. }
  702. .label span {
  703. font-size: 0.2rem;
  704. display: inline-block;
  705. margin-left: 0.08rem;
  706. color: #999999;
  707. }
  708. .zhidu {
  709. display: flex;
  710. height: 0.7rem;
  711. line-height: 0.7rem;
  712. border-bottom: 0.02rem rgb(245, 245, 245) solid;
  713. }
  714. .bgColor {
  715. background-color: white;
  716. }
  717. .zhidu div:nth-child(1) {
  718. width: 27.5%;
  719. padding-left: 6%;
  720. }
  721. .uplod {
  722. padding: 0 0.24rem;
  723. }
  724. </style>
  725. <style>
  726. .btn_plcaeholde .cube-btn {
  727. padding-left: 0;
  728. padding-right: 0;
  729. text-align: left;
  730. color: inherit;
  731. background: none;
  732. border: none;
  733. }
  734. .cube-form_standard .cube-upload-def .cube-upload-btn,
  735. .cube-form_standard .cube-upload-def .cube-upload-file {
  736. margin-left: 3% !important;
  737. }
  738. .sub .cube-btn {
  739. background-color: #005395 !important;
  740. width: 90%;
  741. margin: 0 auto;
  742. border-radius: 8px;
  743. }
  744. .cube-picker-wheel-item {
  745. text-overflow: ellipsis;
  746. }
  747. </style>