repairDetail.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <van-nav-bar title="详情" safe-area-inset-top>
  3. <template #left>
  4. <van-icon
  5. :name="require('@/assets/arrow-left.svg')"
  6. size="24"
  7. @click="backPath"
  8. />
  9. </template>
  10. </van-nav-bar>
  11. <div class="page_info">
  12. <div class="info_list">
  13. <van-cell-group class="cell_title_icon">
  14. <van-cell
  15. title="报修信息"
  16. :icon="require('@/assets/line.svg')"
  17. v-if="
  18. role == 'admin' && (dataForm.status == 2 || dataForm.status == 3)
  19. "
  20. />
  21. <van-cell title="报修时间" :value="dataForm.createDate" />
  22. <van-cell title="报修位置" :value="dataForm.repairPosition" />
  23. <van-cell
  24. title="报修区域"
  25. :value="`${repairRegion_filter(dataForm.repairRegion)}`"
  26. />
  27. <van-cell
  28. title="报修类型"
  29. :value="`${repairType_filter(dataForm.repairType)}`"
  30. />
  31. <van-cell title="联系人" :value="dataForm.contactPerson" />
  32. <van-cell title="联系电话" :value="dataForm.contactPhone" />
  33. <van-cell title="故障描述" :value="dataForm.faultDes" />
  34. <van-cell title="故障照片" :border="false" class="upload_cell">
  35. <template #value>
  36. <van-image
  37. width="80"
  38. height="80"
  39. :src="item"
  40. v-for="(item, index) in imagesList"
  41. :key="item + '_' + index"
  42. />
  43. </template>
  44. </van-cell>
  45. </van-cell-group>
  46. <van-cell-group
  47. class="cell_title_icon"
  48. v-if="role == 'admin' && (dataForm.status == 2 || dataForm.status == 3)"
  49. >
  50. <van-cell title="维修信息" :icon="require('@/assets/line.svg')" />
  51. <van-cell
  52. title="紧急程度"
  53. :value="`${urgency_filter(dataForm.urgency)}`"
  54. />
  55. <van-cell title="维修人员" :value="dataForm.repairPersonName" />
  56. <van-cell title="联系电话" :value="dataForm.repairPersonId" />
  57. <van-cell
  58. title="维修完成时间"
  59. :value="dataForm.repairFinishTime"
  60. v-if="dataForm.status == 3"
  61. />
  62. </van-cell-group>
  63. </div>
  64. </div>
  65. <template v-if="dataForm.status == 2 && role == 'repair'">
  66. <div class="save_btn">
  67. <van-button
  68. block
  69. type="primary"
  70. loading-type="spinner"
  71. :loading="loading"
  72. loading-text="维修完成"
  73. @click="handleClick('finish')"
  74. >
  75. 维修完成
  76. </van-button>
  77. </div>
  78. </template>
  79. <template v-if="role == 'admin' && dataForm.status == 1">
  80. <div class="save_btn">
  81. <van-button
  82. block
  83. type="primary"
  84. loading-type="spinner"
  85. @click="handleClick('dispatch')"
  86. >
  87. 指派维修人员
  88. </van-button>
  89. </div>
  90. </template>
  91. <van-popup
  92. v-model:show="showPopup"
  93. position="bottom"
  94. :style="{ height: '30%' }"
  95. class="popup_info"
  96. >
  97. <van-row class="popup_title">
  98. <van-col :span="24">{{ popupTitle }}</van-col>
  99. </van-row>
  100. <van-divider style="margin: 0" />
  101. <van-form
  102. ref="dataForm"
  103. input-align="right"
  104. error-message-align="right"
  105. @submit="onSubmit"
  106. >
  107. <van-cell-group :border="false">
  108. <van-field
  109. v-model="dataForm.repairPersonName"
  110. label="维修人员"
  111. required
  112. is-link
  113. placeholder="请选择维修人员"
  114. clearable
  115. :rules="[{ required: true, message: '请选择维修人员' }]"
  116. @click="showRepairPersonPicker = true"
  117. />
  118. <van-popup
  119. v-model:show="showRepairPersonPicker"
  120. round
  121. position="bottom"
  122. >
  123. <van-picker
  124. :columns="repairPersonList"
  125. :columns-field-names="customFieldName"
  126. @cancel="showRepairPersonPicker = false"
  127. @confirm="
  128. (value) => {
  129. dataForm.repairPersonId = value.id;
  130. dataForm.repairPersonName = value.name;
  131. showRepairPersonPicker = false;
  132. }
  133. "
  134. />
  135. </van-popup>
  136. <van-field
  137. v-model="dataForm.urgencyName"
  138. label="紧急程度"
  139. required
  140. is-link
  141. placeholder="请选择紧急程度"
  142. clearable
  143. :rules="[{ required: true, message: '请选择紧急程度' }]"
  144. @click="showUrgencyPicker = true"
  145. />
  146. <van-popup v-model:show="showUrgencyPicker" round position="bottom">
  147. <van-picker
  148. :columns="repairUrgencyList"
  149. @cancel="showUrgencyPicker = false"
  150. @confirm="
  151. (value) => {
  152. dataForm.urgency = value.value;
  153. dataForm.urgencyName = value.text;
  154. showUrgencyPicker = false;
  155. }
  156. "
  157. />
  158. </van-popup>
  159. </van-cell-group>
  160. <div class="save_btn">
  161. <van-button
  162. block
  163. type="primary"
  164. :loading="loading"
  165. loading-type="spinner"
  166. loading-text="提交"
  167. native-type="submit"
  168. >
  169. 提交
  170. </van-button>
  171. </div>
  172. </van-form>
  173. </van-popup>
  174. </template>
  175. <script>
  176. import Api from "../utils/api";
  177. import { isEmpty } from "@/utils/index.js";
  178. import VCountUp from "./CountUp";
  179. export default {
  180. components: {
  181. "v-count-up": VCountUp,
  182. },
  183. data() {
  184. return {
  185. role: "",
  186. loading: false,
  187. showImgPreview: false,
  188. imagesList: [],
  189. showPopup: false,
  190. popupTitle: "工单指派",
  191. showRepairPersonPicker: false,
  192. showUrgencyPicker: false,
  193. repairPersonList: [],
  194. customFieldName: {
  195. text: "name",
  196. value: "id",
  197. },
  198. repairUrgencyList: [
  199. { text: "非常紧急", value: 1 },
  200. { text: "紧急", value: 2 },
  201. { text: "普通", value: 3 },
  202. ],
  203. dataForm: {
  204. id: "",
  205. repairPersonId: "",
  206. repairPersonName: "",
  207. urgency: "",
  208. urgencyName: "",
  209. repairTime: "",
  210. repairFinishTime: "",
  211. repairPositionName: "",
  212. repairRegion: "",
  213. status: "",
  214. repairType: "",
  215. contactPerson: "",
  216. contactPhone: "",
  217. faultDes: "",
  218. faultPics: "",
  219. },
  220. };
  221. },
  222. created() {
  223. this.role = localStorage.getItem("role");
  224. this.getDataDetail();
  225. this.getUserList();
  226. },
  227. methods: {
  228. repairType_filter(val) {
  229. if (isEmpty(val)) {
  230. return "";
  231. }
  232. if (val == 1) {
  233. return "水";
  234. }
  235. if (val == 2) {
  236. return "电";
  237. }
  238. if (val == 3) {
  239. return "其他";
  240. }
  241. },
  242. repairRegion_filter(val) {
  243. if (isEmpty(val)) {
  244. return "";
  245. }
  246. if (val == 1) {
  247. return "公共区域";
  248. }
  249. if (val == 2) {
  250. return "室内";
  251. }
  252. },
  253. urgency_filter(val) {
  254. if (isEmpty(val)) {
  255. return "";
  256. }
  257. if (val == 1) {
  258. return "非常紧急";
  259. }
  260. if (val == 2) {
  261. return "紧急";
  262. }
  263. if (val == 3) {
  264. return "普通";
  265. }
  266. },
  267. //获取维修人员
  268. getUserList() {
  269. Api.repairInfoUser({
  270. page: 1,
  271. limit: 100,
  272. }).then((res) => {
  273. if (res.code == 0) {
  274. this.repairPersonList = res.data.list;
  275. }
  276. });
  277. },
  278. getDataDetail() {
  279. Api.repairInfoDetail(this.$route.query.id).then((res) => {
  280. if (res.code == 0) {
  281. this.dataForm = res.data;
  282. this.imagesList = this.dataForm.faultPics.split(",");
  283. } else {
  284. }
  285. });
  286. },
  287. handleClick(type) {
  288. if (type == "finish") {
  289. this.$dialog
  290. .confirm({
  291. message: "请确认是否维修完成",
  292. })
  293. .then(() => {
  294. this.loading = true;
  295. setTimeout(() => {
  296. this.loading = false;
  297. }, 2000);
  298. // on confirm
  299. })
  300. .catch(() => {
  301. // on cancel
  302. });
  303. }
  304. if (type == "dispatch") {
  305. this.showPopup = !this.showPopup;
  306. this.$nextTick(() => {
  307. this.$refs.dataForm.resetValidation();
  308. });
  309. }
  310. },
  311. onSubmit() {
  312. this.$toast.loading({
  313. message: "保存中...",
  314. forbidClick: true,
  315. });
  316. Api.repairInfoDispatch({
  317. id: this.dataForm.id,
  318. repairPersonId: this.dataForm.repairPersonId,
  319. urgency: this.dataForm.urgency,
  320. }).then((res) => {
  321. if (res.code == 0) {
  322. this.$toast.success("保存成功");
  323. this.showPopup = false;
  324. this.getDataDetail();
  325. } else {
  326. this.$toast.fail("保存失败");
  327. }
  328. });
  329. },
  330. backPath() {
  331. this.$router.back();
  332. },
  333. },
  334. };
  335. </script>
  336. <style lang="scss" scoped>
  337. .page_info {
  338. .info_list {
  339. /deep/ {
  340. .upload_cell {
  341. .van-cell__title {
  342. flex: unset;
  343. }
  344. .van-image {
  345. margin-left: 8px;
  346. margin-bottom: 8px;
  347. }
  348. }
  349. .cell_title_icon {
  350. .van-icon {
  351. display: flex;
  352. align-items: center;
  353. }
  354. }
  355. .van-cell__left-icon{
  356. margin-right: 0;
  357. }
  358. }
  359. }
  360. }
  361. </style>
  362. <style lang="scss">
  363. .popup_info {
  364. box-shadow: 0px -10px 20px 0px rgba(27, 32, 38, 0.1);
  365. border-radius: 20px 20px 0px 0px;
  366. /deep/ {
  367. .popup_title {
  368. padding: 14px 0;
  369. font-weight: 600;
  370. font-size: 16px;
  371. color: #333333;
  372. text-shadow: 0px -10px 20px rgba(27, 32, 38, 0.1);
  373. }
  374. }
  375. .van-field__label {
  376. color: #666666;
  377. }
  378. }
  379. </style>