createPatrol.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view>
  3. <view
  4. style="box-shadow: 0px 0px 8px 0px rgba(165, 189, 251, 0.4);width: 96%;border-top-right-radius: 10rpx;margin: 10rpx auto;padding-top: 10rpx;">
  5. <span
  6. style="width: 10rpx;height: 40rpx;background-color: #2979ff;display: block;float: left;margin-top: 20rpx;"></span>
  7. <view style="width: 92%;margin: 0 auto;margin: 0 auto;">
  8. <view
  9. style="display: flex;justify-content: space-between;height: 80rpx;line-height: 80rpx;border-bottom: 1rpx solid #eff4ff;">
  10. <h3>基本信息</h3>
  11. </view>
  12. <view>
  13. <u-form :model="form" ref="uForm" label-width="200">
  14. <view style="width: 100%;">
  15. <u-form-item label="仓库名称:" prop="fWarehouseFid">
  16. <u-input v-model="form.fWarehouseName" type="select"
  17. @click="openWarehouse('fWarehouseFid')" />
  18. </u-form-item>
  19. </view>
  20. <!-- <view style="width: 100%;">
  21. <u-form-item label="巡检日期起:" prop="fInspectorBeginDatetime">
  22. <u-input type="select" v-model="form.fInspectorBeginDatetime"
  23. @click="openCalendar('fInspectorBeginDatetime')" />
  24. </u-form-item>
  25. </view> -->
  26. <!-- <view style="width: 100%;">
  27. <u-form-item label="巡检日期止:" prop="fInspectorEndDatetime">
  28. <u-input v-model="form.fInspectorEndDatetime" type="select"
  29. @click="openCalendar('fInspectorEndDatetime')" />
  30. </u-form-item>
  31. </view> -->
  32. <!-- <view style="width: 100%;">
  33. <u-form-item label="巡检人:" prop="fInspectorId">
  34. <u-input v-model="fInspectorName" type="select"
  35. @click="openInspector('fInspectorId')" />
  36. </u-form-item>
  37. </view> -->
  38. <view style="width: 100%;">
  39. <u-form-item label="备注:" prop="remark">
  40. <u-input type="textarea" height="70" v-model="form.fRemark" />
  41. </u-form-item>
  42. </view>
  43. </u-form>
  44. </view>
  45. </view>
  46. </view>
  47. <view
  48. style="box-shadow: 0px 0px 8px 0px rgba(165, 189, 251, 0.4);width: 96%;border-top-right-radius: 10rpx;margin: 10rpx auto;padding-top: 10rpx;">
  49. <span
  50. style="width: 10rpx;height: 40rpx;background-color: #2979ff;display: block;float: left;margin-top: 20rpx;"></span>
  51. <view style="width: 92%;margin: 0 auto;margin: 0 auto;">
  52. <view
  53. style="display: flex;justify-content: space-between;height: 80rpx;line-height: 80rpx;border-bottom: 1rpx solid #eff4ff;">
  54. <h3>巡检明细</h3>
  55. <!-- <view class="various"><u-icon name="trash" color="#2979ff" size="44" @click="detailRemoval(index)"></u-icon></view> -->
  56. </view>
  57. <view>
  58. <view>
  59. <u-upload @on-remove="onRemove" @on-success="success" :action="action" deletable
  60. :header="headers" :file-list="fileList"></u-upload>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view
  66. style="z-index: 100;width: 100%;position:fixed; bottom:44rpx;background-color: #FFFFFF;padding-left: 20px;padding-right: 20px;">
  67. <u-button type="primary" @click="appCheckCode">确认添加</u-button>
  68. </view>
  69. <u-top-tips ref="uTips"></u-top-tips>
  70. <u-toast ref="uToast" />
  71. <u-calendar v-model="calendar" mode="date" @change="changeData"></u-calendar>
  72. <u-select v-model="warehouse" value-name="fId" label-name="fName" :list="warehouseList"
  73. @confirm="warehouseConfirm"></u-select>
  74. <u-select v-model="inspector" value-name="userId" label-name="userName" :list="inspectorList"
  75. @confirm="inspectorConfirm"></u-select>
  76. <u-picker mode="time" v-model="detailedTime" :params="params" @confirm="confirm"></u-picker>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. form: {
  84. fWarehouseFid: '',
  85. fWarehouseName: '',
  86. fRemark: '',
  87. fPhotoUrl: []
  88. },
  89. fName: '',
  90. headers: {
  91. Authorization: 'Bearer ' + uni.getStorageSync('lifeData').vuex_token
  92. },
  93. action: this.$u.http.config.baseUrl + '/common/upload',
  94. fileList: [],
  95. params: {
  96. year: true,
  97. month: true,
  98. day: true,
  99. hour: true,
  100. minute: true,
  101. second: true
  102. },
  103. fInspectorName: '',
  104. list: [],
  105. rules: {},
  106. calendar: false,
  107. detailedTime: false,
  108. type: '',
  109. index: null,
  110. warehouse: false,
  111. inspector: false,
  112. warehouseList: [],
  113. inspectorList: [],
  114. pictureEist: []
  115. }
  116. },
  117. onReady() {
  118. this.$refs.uForm.setRules(this.rules);
  119. },
  120. created() {
  121. this.$u.get('/basicdata/warehouse/lists?fStatus=0&delFlag=0').then(res => {
  122. this.warehouseList = res.rows
  123. })
  124. this.$u.get('/system/user/selectUserByRole', {
  125. roleName: "巡检员"
  126. }).then(res => {
  127. this.inspectorList = res.rows
  128. })
  129. },
  130. methods: {
  131. newDetails() {
  132. this.list.push({
  133. fWarehouseFid: '',
  134. fWarehouseName: '',
  135. fRemark: '',
  136. fPhotoUrl: []
  137. })
  138. },
  139. //上传成功触发
  140. success(data, index, lists, name) {
  141. this.pictureEist = lists
  142. },
  143. onRemove(index, lists, name) {
  144. this.pictureEist = lists
  145. },
  146. appCheckCode() {
  147. if(this.form.fPhotoUrl){
  148. this.$refs.uToast.show({
  149. title: '请上传附件',
  150. position:'bottom'
  151. })
  152. }
  153. if(this.form.fWarehouseFid){
  154. this.$refs.uToast.show({
  155. title: '请选择仓库名称',
  156. position:'bottom'
  157. })
  158. }
  159. this.pictureEist.forEach(item=>this.form.fPhotoUrl.push({url:item.response.url}))
  160. this.form.fPhotoUrl = JSON.stringify(this.form.fPhotoUrl)
  161. this.$u.post('/warehouse/check/saveCheckItemsDetails', {
  162. ...this.form
  163. }).then(res => {
  164. this.$refs.uToast.show({
  165. title: '创建成功',
  166. type: 'success',
  167. callback() {
  168. uni.navigateBack()
  169. }
  170. })
  171. })
  172. },
  173. //日历确定触发
  174. changeData(e) {
  175. if (this.type == 'fInspectorBeginDatetime') this.form.fInspectorBeginDatetime = e.result + ' 00:00:00'
  176. if (this.type == 'fInspectorEndDatetime') this.form.fInspectorEndDatetime = e.result + ' 23:59:59'
  177. },
  178. // 计划日期选择
  179. confirm(e) {
  180. console.log(e)
  181. if (this.type == 'fInspectionDatetime') this.list[this.index].fInspectionDatetime = e.year + "-" + e
  182. .month + "-" + e.day + ' ' + e.hour + ":" + e.minute + ":" + e.second
  183. },
  184. //打开日历
  185. openCalendar(type, index) {
  186. if (type == 'fInspectorBeginDatetime' && index == undefined) {
  187. this.type = type
  188. this.calendar = !this.calendar
  189. }
  190. if (type == 'fInspectorEndDatetime' && index == undefined) {
  191. this.type = type
  192. this.calendar = !this.calendar
  193. }
  194. if (type == 'fInspectionDatetime' && (index == 0 || index > 0)) {
  195. this.type = type
  196. this.index = index
  197. this.detailedTime = !this.detailedTime
  198. }
  199. },
  200. //打开仓库
  201. openWarehouse(store, index) {
  202. if (store == 'fWarehouseFid' && index == undefined) {
  203. this.store = store
  204. this.warehouse = !this.warehouse
  205. }
  206. if (store == 'fWarehouseFidName' && (index == 0 || index > 0)) {
  207. this.store = store
  208. this.index = index
  209. this.warehouse = !this.warehouse
  210. }
  211. },
  212. //仓库选择
  213. warehouseConfirm(e) {
  214. if (this.store == 'fWarehouseFid') {
  215. this.form.fWarehouseFid = e[0].value
  216. this.form.fWarehouseName = e[0].label
  217. }
  218. if (this.store == 'fWarehouseFidName') {
  219. this.list[this.index].fWarehouseFid = e[0].value
  220. this.list[this.index].fWarehouseFidName = e[0].label
  221. }
  222. },
  223. openInspector(people, index) {
  224. if (people == 'fInspectorId' && index == undefined) {
  225. this.people = people
  226. this.inspector = !this.inspector
  227. }
  228. if (people == 'fInspectorName' && (index == 0 || index > 0)) {
  229. this.people = people
  230. this.index = index
  231. this.inspector = !this.inspector
  232. }
  233. },
  234. //明细移除
  235. detailRemoval(index) {
  236. this.list.splice(index, 1);
  237. },
  238. //选择巡检员
  239. inspectorConfirm(e) {
  240. if (this.people == 'fInspectorId') {
  241. this.form.fInspectorId = e[0].value
  242. this.fInspectorName = e[0].label
  243. }
  244. if (this.people == 'fInspectorName') {
  245. this.list[this.index].fInspectorId = e[0].value
  246. this.list[this.index].fInspectorName = e[0].label
  247. }
  248. },
  249. tips(content) {
  250. this.$refs.uTips.show({
  251. title: content,
  252. type: 'error',
  253. duration: '2300'
  254. })
  255. },
  256. }
  257. }
  258. </script>
  259. <style lang="scss" scoped>
  260. </style>