buildIncident.vue 17 KB

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