buildIncident.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <view class="buildIncident">
  3. <!-- 原来的scroll-view -->
  4. <view class="body view-body">
  5. <view class="form_item">
  6. <view class="title select"><text class="required newicon newicon-bitian"></text>院区:</view>
  7. <!-- <uni-data-select class="value" v-model="incidentData.branch" :localdata="dataInfo.branchList" :clear="false" placeholder="请选择院区" :class="{formRed: isSubmit && !incidentData.branch}" @change="changeBranch"></uni-data-select> -->
  8. <uni-data-picker class="value" placeholder="请选择院区"
  9. :localdata="dataInfo.branchList" v-model="incidentData.branch" :clear-icon="false"
  10. :class="{formRed: isSubmit && !incidentData.branch}" @change="changeBranch">
  11. </uni-data-picker>
  12. <!-- <view class="value size-14">
  13. {{loginUserStore.loginUser.user.currentHospital.parent?
  14. loginUserStore.loginUser.user.currentHospital.parent.hosName:
  15. loginUserStore.loginUser.user.currentHospital.hosName}}
  16. </view> -->
  17. </view>
  18. <view class="form_item">
  19. <view class="title"><text class="required newicon newicon-bitian"></text>报修科室:</view>
  20. <view class="value category" @click="selectDepartment">
  21. <text class="categoryName ellipsis-multiline">{{incidentData.department ? incidentData.department.dept : ''}}</text>
  22. <text class="newicon newicon-weibiaoti2010104"></text>
  23. </view>
  24. </view>
  25. <view class="form_item">
  26. <view class="title"><text class="required newicon newicon-bitian transparent"></text>报修人:</view>
  27. <view class="value category" @click="selectRequester">
  28. <text class="categoryName ellipsis-multiline">{{incidentData.requester ? incidentData.requester.name : ''}}</text>
  29. <text class="newicon newicon-weibiaoti2010104"></text>
  30. </view>
  31. </view>
  32. <view class="form_item">
  33. <view class="title select"><text class="required newicon newicon-bitian transparent"></text>联系人:</view>
  34. <uni-easyinput class="value" v-model="incidentData.contacts" placeholder="请输入联系人" />
  35. </view>
  36. <view class="form_item">
  37. <view class="title select"><text class="required newicon newicon-bitian"></text>联系电话:</view>
  38. <uni-easyinput class="value" v-model="incidentData.contactsInformation" placeholder="请输入联系电话" :class="{formRed: isSubmit && !incidentData.contactsInformation.trim()}" />
  39. </view>
  40. <view class="form_item">
  41. <view class="title"><text class="required newicon newicon-bitian transparent"></text>楼栋楼层:</view>
  42. <view class="value category" @click="selectAreaPlace">
  43. <text class="categoryName ellipsis-multiline" v-if="incidentData.place">{{incidentData.place ? incidentData.place.building.buildingName:''}} {{ incidentData.place&&incidentData.place.floor?incidentData.place.floor.floorName : incidentData.place.floorName}}</text>
  44. <text class="newicon newicon-weibiaoti2010104"></text>
  45. </view>
  46. </view>
  47. <view class="form_item">
  48. <view class="title select"><text class="required newicon newicon-bitian transparent"></text>详细地址:</view>
  49. <uni-easyinput class="value" v-model="incidentData.houseNumber" placeholder="请输入详细地址" />
  50. </view>
  51. <view class="form_item">
  52. <view class="title"><text class="required newicon newicon-bitian"></text>故障现象:</view>
  53. <view class="value category" @click="selectCategory">
  54. <text class="categoryName ellipsis-multiline">{{incidentData.category ? incidentData.category.mutiCategory : ''}}</text>
  55. <text class="newicon newicon-weibiaoti2010104"></text>
  56. </view>
  57. </view>
  58. <view class="form_item">
  59. <view class="title select"><text class="required newicon newicon-bitian"></text>故障来源:</view>
  60. <!-- <uni-data-select readonly class="value" v-model="incidentData.source" :localdata="dataInfo.sourceList" placeholder="请选择故障来源" :class="{formRed: isSubmit && !incidentData.source}"></uni-data-select> -->
  61. <uni-data-picker class="value" placeholder="请选择故障来源"
  62. :localdata="dataInfo.sourceList" v-model="incidentData.source"
  63. :clear-icon="false" :class="{formRed: isSubmit && !incidentData.source}">
  64. </uni-data-picker>
  65. </view>
  66. <view class="form_item">
  67. <view class="title select"><text class="required newicon newicon-bitian"></text>优先级:</view>
  68. <!-- <uni-data-select placement="top" readonly class="value" v-model="incidentData.priority" :localdata="dataInfo.priorityList" placeholder="请选择优先级" :class="{formRed: isSubmit && !incidentData.priority}"></uni-data-select> -->
  69. <uni-data-picker placement="top" class="value" placeholder="请选择优先级"
  70. :localdata="dataInfo.priorityList" v-model="incidentData.priority"
  71. :clear-icon="false" :class="{formRed: isSubmit && !incidentData.priority}">
  72. </uni-data-picker>
  73. </view>
  74. <view class="form_item column">
  75. <view class="title select"><text class="required newicon newicon-bitian"></text>故障描述:</view>
  76. <uni-easyinput class="value" type="textarea" v-model="incidentData.description" placeholder="请输入故障描述" :class="{formRed: isSubmit && !incidentData.description.trim()}" />
  77. </view>
  78. <view class="form_item_column">
  79. <view class="form_item">
  80. <view class="title"><text class="required newicon newicon-bitian transparent"></text>报修图片:</view>
  81. <view class="value">
  82. <uni-file-picker ref="handlerImgRef" v-model="incidentData.repairImgList" limit="3" @success="handlerImgSuccess" @fail="handlerImgFail" @select="handlerImgSelect" @delete="handlerImgDelete"></uni-file-picker>
  83. </view>
  84. </view>
  85. <view class="form_item">
  86. <view class="title transparent"><text class="required newicon newicon-bitian transparent"></text>报修图片:</view>
  87. <view class="value">
  88. <text class="imgTips ellipsis">(支持JPG/PNG格式图片,单张大小10M以内)</text>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="foot_common_btns">
  94. <button @click="goBack" type="default" class="cancelButton btn">返回</button>
  95. <button @click="submit" type="default" class="primaryButton btn">下一步</button>
  96. </view>
  97. </view>
  98. </template>
  99. <script setup>
  100. import { ref, reactive } from 'vue'
  101. import { onLoad } from '@dcloudio/uni-app'
  102. import { api_branch, api_getDictionary, getFetchDataList, api_incidentTask } from "@/http/api.js"
  103. import { defaultColor } from '@/static/js/theme.js'
  104. import { useSetTitle } from '@/share/useSetTitle.js'
  105. import { useGoBack } from '@/share/useGoBack.js'
  106. import { useLoginUserStore } from '@/stores/loginUser'
  107. import { useIncidentBuildStore } from '@/stores/incidentBuild'
  108. import { useHandlerStore } from '@/stores/handler'
  109. import { useUploadFile } from '@/share/useUploadFile.js'
  110. useSetTitle();
  111. const loginUserStore = useLoginUserStore();
  112. const incidentBuildStore = useIncidentBuildStore();
  113. const handlerStore = useHandlerStore();
  114. const { uploadFile } = useUploadFile();
  115. const { goBack } = useGoBack();
  116. // 主题颜色
  117. const primaryColor = ref(defaultColor)
  118. // 工单对象
  119. const incidentData = reactive({
  120. "deleteFlag": 0,
  121. "duty": undefined,
  122. "department": undefined,
  123. "contactsInformation": '',
  124. "contacts": '',
  125. "branch": undefined,
  126. "area": undefined,
  127. "place": undefined,
  128. "houseNumber": '',
  129. "category": undefined,
  130. "priority": undefined,
  131. "source": undefined,
  132. "title": '',
  133. "description": '',
  134. "repairType": undefined,
  135. "requester":undefined,
  136. "acceptUser": loginUserStore.loginUser.user,
  137. repairImgList: [],//报修图片列表
  138. })
  139. // 报修图片
  140. const handlerImgRef = ref(null)
  141. // 数据
  142. const dataInfo = reactive({
  143. branchList: [], //院区列表
  144. sourceList: [], //故障来源列表
  145. priorityList: [], //优先级列表
  146. })
  147. // 是否提交
  148. const isSubmit = ref(false)
  149. // 上传报修图片成功
  150. function handlerImgSuccess(e){
  151. incidentData.repairImgList.forEach(v => {
  152. v.url = v.path;
  153. })
  154. console.log(incidentData.repairImgList);
  155. }
  156. // 上传报修图片失败
  157. function handlerImgFail(e){
  158. incidentData.repairImgList.forEach(v => {
  159. v.url = v.path;
  160. })
  161. console.log(incidentData.repairImgList);
  162. }
  163. // 选择上传图片
  164. function handlerImgSelect(e){
  165. incidentData.repairImgList = incidentData.repairImgList.concat(e.tempFiles);
  166. console.log(incidentData.repairImgList);
  167. }
  168. // 删除上传图片
  169. function handlerImgDelete(e){
  170. incidentData.repairImgList = incidentData.repairImgList.filter(v => e.tempFile.uuid != v.uuid);
  171. console.log(incidentData.repairImgList);
  172. }
  173. // 选择故障现象
  174. function selectCategory(){
  175. incidentBuildStore.setIncidentBuildData(incidentData, 'buildIncident');
  176. uni.navigateTo({
  177. url: `/pages/categoryOne/categoryOne`
  178. })
  179. }
  180. // 选择楼栋楼层
  181. function selectAreaPlace(){
  182. incidentBuildStore.setIncidentBuildData(incidentData, 'buildIncident', 'area');
  183. uni.navigateTo({
  184. url: `/pages/searchArea/searchArea`
  185. })
  186. }
  187. // 跳转到搜索报修科室
  188. function selectDepartment(){
  189. incidentBuildStore.setIncidentBuildData(incidentData, 'buildIncident', 'department');
  190. uni.navigateTo({
  191. url: `/pages/searchDept/searchDept`
  192. })
  193. }
  194. // 跳转到搜索报修人
  195. function selectRequester(){
  196. incidentBuildStore.setIncidentBuildData(incidentData, 'buildIncident', 'requester');
  197. uni.navigateTo({
  198. url: `/pages/searchUser/searchUser`
  199. })
  200. }
  201. // 获取院区列表
  202. function getBranchs(){
  203. let arr = loginUserStore.loginUser.hospital.filter(i=>i.parent==undefined)
  204. dataInfo.branchList = arr.map(v => ({
  205. text: v.hosName,
  206. value: v.id,
  207. }));
  208. if(!incidentData.branch){
  209. if(loginUserStore.loginUser.user.currentHospital.parent){
  210. incidentData.branch = loginUserStore.loginUser.user.currentHospital.parent.id
  211. }else{
  212. incidentData.branch = loginUserStore.loginUser.user.currentHospital.id
  213. }
  214. }
  215. // uni.showLoading({
  216. // title: "加载中",
  217. // mask: true,
  218. // });
  219. // let postData = {
  220. // "idx": 0,
  221. // "sum": 9999,
  222. // parent:{id:loginUserStore.loginUser.user.currentHospital.id}
  223. // };
  224. // api_branch(postData).then(res => {
  225. // uni.hideLoading();
  226. // if(res.status == 200){
  227. // res.list = res.list || [];
  228. // dataInfo.branchList = res.list.map(v => ({
  229. // text: v.hosName,
  230. // value: v.id,
  231. // }));
  232. // if(!incidentBuildStore.incidentBuild.data){
  233. // if(loginUserStore.loginUser.user.duty){
  234. // // 当前的所属责任科室
  235. // incidentData.branch = loginUserStore.loginUser.user.duty.branch;
  236. // }else if(loginUserStore.loginUser.user.branch){
  237. // // 当前的所属院区
  238. // incidentData.branch = loginUserStore.loginUser.user.branch.id;
  239. // }
  240. // }
  241. // }else{
  242. // uni.showToast({
  243. // icon: 'none',
  244. // title: res.msg || '请求数据失败!'
  245. // });
  246. // }
  247. // })
  248. }
  249. // 获取故障来源列表
  250. function getSources(){
  251. uni.showLoading({
  252. title: "加载中",
  253. mask: true,
  254. });
  255. let postData = {
  256. "key": 'incident_source',
  257. "type": "list",
  258. };
  259. api_getDictionary(postData).then(res => {
  260. uni.hideLoading();
  261. res = res || [];
  262. dataInfo.sourceList = res.map(v => ({
  263. text: v.name,
  264. value: v.id,
  265. key: v.value,
  266. }));
  267. let discover = dataInfo.sourceList.find(v => v.key === 'leader');
  268. if(discover){
  269. incidentData.source = discover.value;
  270. }
  271. })
  272. }
  273. // 获取优先级列表
  274. function getPrioritys(){
  275. uni.showLoading({
  276. title: "加载中",
  277. mask: true,
  278. });
  279. let postData = {
  280. priority: {},
  281. idx: 0,
  282. sum: 9999,
  283. };
  284. getFetchDataList("simple/data", "priority", postData)
  285. .then((data) => {
  286. uni.hideLoading();
  287. dataInfo.priorityList = data.list.map(v => ({
  288. text: v.name,
  289. value: v.id,
  290. }));
  291. });
  292. }
  293. // 选择院区
  294. function changeBranch(){
  295. incidentData.department = undefined;
  296. incidentData.contactsInformation = '';
  297. incidentData.place = undefined;
  298. incidentData.houseNumber = undefined;
  299. }
  300. // 处理提交事件
  301. function handlerOrder(){
  302. let postData = {
  303. incident: dataInfo.incidentData,
  304. }
  305. postData.incident.handleDescription = dataInfo.handleDescription;
  306. postData.incident.handleCategory = {id: dataInfo.handleCategory};
  307. postData.incident.closecode = {id: dataInfo.closecode};
  308. postData.incident.category = dataInfo.category;
  309. postData.incident.synergetic = dataInfo.synergetic;
  310. return api_incidentTask('accept', postData);
  311. }
  312. // 报修图片
  313. function handlerOrderImg(imgObj){
  314. return uploadFile(imgObj, 'incident', dataInfo.incidentId)
  315. }
  316. // 获取优先级
  317. function getPriorityData(){
  318. let postData = {
  319. idx: 0,
  320. sum: 9999,
  321. incidentCategoryConfig: {
  322. categoryId: incidentData.category.id,
  323. dutyId: loginUserStore.loginUser.user.currentHospital.id,
  324. },
  325. };
  326. getFetchDataList("simple/data", "incidentCategoryConfig", postData).then(res => {
  327. let item = res.list.find(i=>i.categoryId == incidentData.category.id)
  328. incidentData.priority = item.priority
  329. })
  330. }
  331. // 提交
  332. function submit(){
  333. isSubmit.value = true;
  334. if(!incidentData.branch){
  335. uni.showToast({
  336. icon: 'none',
  337. title: '请选择院区'
  338. });
  339. return;
  340. }
  341. if(!incidentData.department){
  342. uni.showToast({
  343. icon: 'none',
  344. title: '请选择报修科室'
  345. });
  346. return;
  347. }
  348. if(!incidentData.contactsInformation.trim()){
  349. uni.showToast({
  350. icon: 'none',
  351. title: '请填写联系电话'
  352. });
  353. return;
  354. }
  355. if(!incidentData.category){
  356. uni.showToast({
  357. icon: 'none',
  358. title: '请选择故障现象'
  359. });
  360. return;
  361. }
  362. if(!incidentData.source){
  363. uni.showToast({
  364. icon: 'none',
  365. title: '请选择故障来源'
  366. });
  367. return;
  368. }
  369. if(!incidentData.priority){
  370. uni.showToast({
  371. icon: 'none',
  372. title: '请选择优先级'
  373. });
  374. return;
  375. }
  376. if(!incidentData.description.trim()){
  377. uni.showToast({
  378. icon: 'none',
  379. title: '请填写故障描述'
  380. });
  381. return;
  382. }
  383. // 处理责任科室
  384. if(incidentData.category.branchType == 1){
  385. // 分院区
  386. if(incidentData.branch){
  387. let dutyConfig = incidentData.category.branchUserGroups.find(v=>v.branchId == incidentData.branch);
  388. if(dutyConfig && dutyConfig.dutyId && dutyConfig.dutyName){
  389. incidentData.duty = {id:dutyConfig.dutyId,dept:dutyConfig.dutyName};
  390. }else{
  391. incidentData.duty = undefined;
  392. }
  393. }else{
  394. incidentData.duty = undefined;
  395. }
  396. }else{
  397. // 不分院区
  398. incidentData.duty = incidentData.category.dutyDepartment;
  399. }
  400. incidentData.title = incidentData.category.category;
  401. console.log(777,incidentData.branch)
  402. incidentBuildStore.setIncidentBuildData(incidentData, 'buildIncident');
  403. uni.navigateTo({
  404. url: '/pages/assign/assign'
  405. })
  406. }
  407. onLoad((option) => {
  408. handlerStore.clearHandlerData();
  409. if(incidentBuildStore.incidentBuild.data){
  410. Object.assign(
  411. incidentData,
  412. incidentBuildStore.incidentBuild.data,
  413. {
  414. priority: incidentBuildStore.incidentBuild.data.category ? (incidentBuildStore.incidentBuild.data.category.priority ? incidentBuildStore.incidentBuild.data.category.priority.id : undefined) : undefined,
  415. description: incidentBuildStore.incidentBuild.data.category ? incidentBuildStore.incidentBuild.data.category.mutiCategory : undefined,
  416. },
  417. );
  418. // 修改报修科室,则回显楼栋,楼层,详细地址,联系电话
  419. if(incidentBuildStore.incidentBuild.sign === 'department'){
  420. if(incidentData.department){
  421. incidentData.place = incidentData.department || undefined;
  422. incidentData.houseNumber = incidentData.department.address || '';
  423. incidentData.contactsInformation = incidentData.department.manyPhone ? incidentData.department.manyPhone.split(',')[0] : '';
  424. }
  425. }
  426. if(incidentData.category && incidentData.category.id){
  427. getPriorityData()
  428. }
  429. }
  430. getBranchs();
  431. getSources();
  432. getPrioritys();
  433. })
  434. </script>
  435. <style lang="scss" scoped>
  436. .buildIncident{
  437. height: 100%;
  438. display: flex;
  439. flex-direction: column;
  440. justify-content: space-between;
  441. .body{
  442. padding: 0 24rpx;
  443. box-sizing: border-box;
  444. flex: 1;
  445. min-height: 0;
  446. .form_item{
  447. display: flex;
  448. align-items: center;
  449. padding-top: 24rpx;
  450. min-height: 86rpx;
  451. &.column{
  452. height: auto;
  453. flex-direction: column;
  454. align-items: flex-start;
  455. .title{
  456. margin-right: 0;
  457. }
  458. .value{
  459. margin-top: 10rpx;
  460. padding-left: 20rpx;
  461. box-sizing: border-box;
  462. }
  463. .tips{
  464. padding: 24rpx;
  465. text-align: center;
  466. font-size: 22rpx;
  467. color: #909399;
  468. width: 100%;
  469. box-sizing: border-box;
  470. }
  471. }
  472. .title{
  473. font-size: 26rpx;
  474. display: flex;
  475. align-items: center;
  476. margin-right: 12rpx;
  477. flex-shrink: 0;
  478. &.select{
  479. width: calc(5em + 20rpx);
  480. }
  481. }
  482. .value{
  483. width: 100%;
  484. &.category{
  485. width: 100%;
  486. display: flex;
  487. justify-content: space-between;
  488. align-items: center;
  489. .categoryName{
  490. font-size: 26rpx;
  491. color: #555;
  492. flex: 1;
  493. }
  494. .newicon-weibiaoti2010104{
  495. color: $uni-primary;
  496. margin-left: 24rpx;
  497. }
  498. }
  499. .imgTips{
  500. color: #909399;
  501. font-size: 22rpx;
  502. }
  503. }
  504. .size-14{
  505. font-size: 26rpx;
  506. }
  507. }
  508. }
  509. }
  510. </style>