guarantee.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <!-- 发布任务 -->
  3. <view class="u-padding-30">
  4. <u-form>
  5. <u-form-item>
  6. <view class="item-title">任务标题</view>
  7. <u-input placeholder="任务标题" border :customStyle="{paddingRight:'22rpx'}" v-model="form.title" />
  8. </u-form-item>
  9. <u-form-item>
  10. <view class="item-title">任务类型</view>
  11. <u-input @click="selceshow=true" type="select" border v-model="selectValue" placeholder="任务类型"
  12. :customStyle="{paddingRight:'22rpx'}" />
  13. <u-select v-model="selceshow" :list="list" @confirm="confirm"></u-select>
  14. </u-form-item>
  15. <u-form-item>
  16. <view class="item-title">具体位置</view>
  17. <u-input @click="pointShow=true" type="select" border v-model="pointValue" placeholder="具体位置"
  18. :customStyle="{paddingRight:'22rpx'}" />
  19. <u-select v-model="pointShow" mode="mutil-column-auto" value-name="id" label-name="name" :list="pointList" @confirm="confirmPoint"></u-select>
  20. </u-form-item>
  21. <u-form-item>
  22. <view class="item-title">所属系统</view>
  23. <u-input @click="systemShow=true" type="select" border v-model="systemValue" placeholder="所属系统"
  24. :customStyle="{paddingRight:'22rpx'}" />
  25. <u-select v-model="systemShow" :list="systemList" @confirm="confirmSystem"></u-select>
  26. </u-form-item>
  27. <u-form-item>
  28. <view class="item-title">要求完成时间</view>
  29. <u-picker @confirm="pickermeth" :params="params" v-model="show" mode="time"></u-picker>
  30. <u-input placeholder="要求完成时间" type="select" @click="show=true" border v-model="form.finishTime"
  31. :customStyle="{paddingRight:'22rpx'}" />
  32. </u-form-item>
  33. <u-form-item>
  34. <view class="item-title">任务内容</view>
  35. <u-input type="Textarea" :customStyle="{paddingRight:'22rpx'}" height="60" border
  36. v-model="form.content" />
  37. </u-form-item>
  38. <u-form-item>
  39. <view class="item-title">任务图片</view>
  40. <view class="item-images u-padding-10">
  41. <c-img @changeImg="changeImg($event)"></c-img>
  42. </view>
  43. </u-form-item>
  44. <u-form-item>
  45. <view class="u-flex">
  46. <view class="item-title">执行人员</view>
  47. <navigator hover-class="none" url="../addppeople/addppeople" class="u-m-l-30 u-f-28 u-flex "
  48. style="color: #333333;">
  49. <view class="add">+</view>
  50. <view v-for="(index,key) in peopleList" :key="key" style="margin-right: 5px;">
  51. {{index.execUserName}}
  52. </view>
  53. <view class="u-m-l-20" style="color: #4A8BFF;">添加</view>
  54. </navigator>
  55. </view>
  56. </u-form-item>
  57. <u-form-item>
  58. <view @click="sumit" class="submit">确定</view>
  59. </u-form-item>
  60. </u-form>
  61. <u-toast ref="uToast" />
  62. </view>
  63. </template>
  64. <script>
  65. import cImg from '@/components/c-img/index.vue'
  66. import dayjs from "dayjs";
  67. import {
  68. addTask,
  69. building,
  70. floor,
  71. room
  72. } from "@/api/index.js";
  73. export default {
  74. components: {
  75. cImg,
  76. },
  77. data() {
  78. return {
  79. show: false,
  80. selceshow: false,
  81. pointShow: false,
  82. systemShow:false,
  83. form: {
  84. title: undefined,
  85. type: undefined,
  86. roomId:undefined,
  87. belongSystem:undefined,
  88. content: undefined,
  89. finishTime: undefined,
  90. images: undefined,
  91. executors: [],
  92. },
  93. peopleList: "",
  94. params: {
  95. year: true,
  96. month: true,
  97. day: true,
  98. hour: true,
  99. minute: true,
  100. second: true,
  101. province: true,
  102. city: true,
  103. area: true,
  104. timestamp: true,
  105. },
  106. list: [{
  107. value: 1,
  108. label: "一般任务",
  109. },
  110. {
  111. value: 2,
  112. label: "较急任务",
  113. },
  114. {
  115. value: 3,
  116. label: "紧急任务",
  117. },
  118. ],
  119. systemList:[{
  120. value: "配电",
  121. label: "配电",
  122. },
  123. {
  124. value: "照明",
  125. label: "照明",
  126. },
  127. {
  128. value: "监控",
  129. label: "监控",
  130. },
  131. {
  132. value: "电梯",
  133. label: "电梯",
  134. },
  135. {
  136. value: "BA",
  137. label: "BA",
  138. },
  139. {
  140. value: "门禁",
  141. label: "门禁",
  142. },
  143. {
  144. value: "给排水",
  145. label: "给排水",
  146. },
  147. {
  148. value: "消防",
  149. label: "消防",
  150. },
  151. {
  152. value: "空调",
  153. label: "空调",
  154. },
  155. {
  156. value: "综合土建",
  157. label: "综合土建",
  158. },
  159. {
  160. value: "动环",
  161. label: "动环",
  162. },
  163. {
  164. value: "工器具",
  165. label: "工器具",
  166. },
  167. {
  168. value: "机柜",
  169. label: "机柜",
  170. },
  171. ],
  172. pointList:[],//具体位置数组
  173. selectValue: "",
  174. pointValue:'',
  175. systemValue:''
  176. };
  177. },
  178. onLoad() {
  179. this.getBuilding()
  180. },
  181. onShow() {
  182. this.peopleList = this.$store.state.user.people;
  183. this.form.executors = []
  184. if (this.peopleList) {
  185. this.peopleList.forEach(Element => {
  186. this.form.executors.push(Element.execUserId)
  187. })
  188. this.form.executors = JSON.parse(JSON.stringify(this.form.executors))
  189. }
  190. this.$store.state.user.people = "";
  191. },
  192. methods: {
  193. //获取楼栋
  194. async getBuilding() {
  195. let {
  196. data
  197. } = await building();
  198. this.pointList.length = 0;
  199. data.forEach(i => {
  200. this.pointList.push(i)
  201. });
  202. for (let i = 0, len = this.pointList.length; i < len; i++) {
  203. await this.getFloor(this.pointList[i].id, i)
  204. for (let j = 0, len = this.pointList[i].children.length; j < len; j++) {
  205. await this.getRoom(this.pointList[i].children[j].id, i, j)
  206. }
  207. }
  208. },
  209. //获取楼层
  210. async getFloor(buildingId, i) {
  211. let {
  212. data
  213. } = await floor(buildingId)
  214. this.pointList[i].children = [];
  215. data.forEach(ite => {
  216. this.pointList[i].children.push(ite)
  217. })
  218. },
  219. //获取房间
  220. async getRoom(roomId, i, j) {
  221. let {
  222. data
  223. } = await room(roomId)
  224. this.pointList[i].children[j].children = [];
  225. data.forEach(ite => {
  226. this.pointList[i].children[j].children.push(ite)
  227. })
  228. },
  229. //获取图片组件穿过来的图片
  230. changeImg(img) {
  231. this.form.images = img;
  232. },
  233. //发布任务
  234. sumit() {
  235. addTask(
  236. this.form
  237. ).then((data) => {
  238. const {
  239. code,
  240. message
  241. } = data;
  242. if (code == 200) {
  243. this.$refs.uToast.show({
  244. title: "发布成功",
  245. type: 'success',
  246. callback: () => {
  247. uni.navigateBack(1);
  248. },
  249. });
  250. } else {
  251. this.$refs.uToast.show({
  252. title: message,
  253. });
  254. }
  255. });
  256. },
  257. //时间选择器
  258. pickermeth(timer) {
  259. const {
  260. timestamp
  261. } = timer;
  262. let ti = dayjs(timestamp * 1000).format("YYYY-MM-DD HH:mm:ss");
  263. this.form.finishTime = ti;
  264. },
  265. //任务类型确认
  266. confirm(e) {
  267. this.form.type = e[0].value;
  268. this.selectValue = e[0].label;
  269. },
  270. //所属系统确认
  271. confirmSystem(e) {
  272. this.form.belongSystem = e[0].value;
  273. this.systemValue = e[0].label;
  274. },
  275. //具体位置确认
  276. confirmPoint(e) {
  277. this.form.roomId = e[2].value;
  278. this.pointValue = `${e[0].label}/${e[1].label}/${e[2].label}`
  279. }
  280. },
  281. };
  282. </script>
  283. <style>
  284. .item-title {
  285. font-size: 28rpx;
  286. font-family: Microsoft YaHei-3970(82674968);
  287. font-weight: 400;
  288. color: #333333;
  289. }
  290. .item-images {
  291. width: 690rpx;
  292. border: 1rpx solid #dcdfe6;
  293. border-radius: 4rpx;
  294. }
  295. .upload-image {
  296. display: flex;
  297. line-height: 60rpx;
  298. justify-content: center;
  299. width: 76rpx;
  300. height: 76rpx;
  301. background: #a9a9a9;
  302. font-size: 74rpx;
  303. }
  304. .add {
  305. width: 47rpx;
  306. height: 47rpx;
  307. border-radius: 50%;
  308. line-height: 31rpx;
  309. text-align: center;
  310. color: #4a8bff;
  311. border: 2px solid #4a8bef;
  312. font-size: 45rpx;
  313. position: relative;
  314. display: flex;
  315. justify-content: center;
  316. }
  317. .submit {
  318. width: 690rpx;
  319. height: 90rpx;
  320. background: #4a8bff;
  321. border-radius: 4rpx;
  322. font-size: 28rpx;
  323. line-height: 90rpx;
  324. text-align: center;
  325. font-family: Microsoft YaHei-3970(82674968);
  326. font-weight: bold;
  327. color: #ffffff;
  328. margin-top: 50rpx;
  329. }
  330. </style>