manualCheckPop.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <!-- 提交审批 -->
  3. <view class="assign-container">
  4. <u-popup :show="popShow" @close="close">
  5. <view class="fixed-bottom">
  6. <view class="state-wrap">
  7. <view class="label">
  8. <text class="bt">*</text>
  9. 状态
  10. </view>
  11. <view class="value-wrap">
  12. <u-radio-group v-model="form.state" placement="row" size="30">
  13. <u-radio
  14. :customStyle="{ marginLeft: '20rpx' }"
  15. v-for="(item, index) in stateList"
  16. :key="index"
  17. :label="item.label"
  18. :name="item.value"
  19. activeColor="#157a2c"
  20. >
  21. </u-radio>
  22. </u-radio-group>
  23. </view>
  24. </view>
  25. <textarea
  26. class="textarea"
  27. v-model="form.describe"
  28. placeholder-style="color:#AAAAAA"
  29. placeholder="补充描述"
  30. />
  31. <view class="sc-wrap">
  32. <view class="title"> 拍照记录 </view>
  33. <uni-file-picker
  34. :limit="3"
  35. v-model="FileImgList"
  36. fileMediatype="image"
  37. mode="grid"
  38. @select="handlImageSelect"
  39. @delete="handlImagDeletee"
  40. />
  41. </view>
  42. <view class="btn-wrap">
  43. <button type="primary" class="qr-btn" @click="submit">
  44. 确认状态
  45. </button>
  46. <button type="primary" class="qx-btn" @click="close">取消</button>
  47. </view>
  48. </view>
  49. </u-popup>
  50. </view>
  51. </template>
  52. <script>
  53. import { post, get, postJ } from '@/utils/api.js'
  54. export default {
  55. props: ['workOrderId', 'planInventoryId', 'bizType'],
  56. data () {
  57. return {
  58. popShow: false,
  59. form: {
  60. state: '',
  61. describe: '',
  62. repairsImg: []
  63. },
  64. FileImgList: [],
  65. stateList: [
  66. {
  67. label: '正常',
  68. value: 4
  69. },
  70. {
  71. label: '丢失',
  72. value: 1
  73. },
  74. {
  75. label: '破损',
  76. value: 2
  77. }
  78. ],
  79. dataInfo: '',
  80. dict: {
  81. assetTypeDict: {
  82. 1: 'SHENGCHANSHEBEI',
  83. 2: 'ZHOUMIN',
  84. 3: 'WULIAO',
  85. 4: 'CHANPIN',
  86. 5: 'ZHOUZHUANCHE',
  87. 6: 'MOJU',
  88. 7: 'BEIPINBEIJIAN'
  89. }
  90. }
  91. }
  92. },
  93. methods: {
  94. open (item) {
  95. this.popShow = true
  96. this.dataInfo = JSON.parse(JSON.stringify(item))
  97. },
  98. close () {
  99. this.form = {
  100. state: '',
  101. describe: '',
  102. repairsImg: []
  103. }
  104. this.popShow = false
  105. },
  106. submit () {
  107. if (!this.form.state) {
  108. uni.showToast({
  109. title: '请选择状态',
  110. icon: 'none'
  111. })
  112. return
  113. }
  114. let par = this.dataInfo
  115. par.accessUrl = this.form.repairsImg.map(n => {
  116. return {
  117. url: n.url,
  118. size: n.size,
  119. name: n.name,
  120. type: n.extname
  121. }
  122. })
  123. par.remark = this.form.describe
  124. par.equStatus = this.form.state
  125. par.assetTypeDict = par.assetTypeDict
  126. par.workOrderId = this.workOrderId
  127. par.planInventoryId = this.planInventoryId
  128. par.bizType = Number(this.bizType)
  129. postJ(this.apiUrl + '/repertoryCheck/saveOrModify', par).then(res => {
  130. if (res.success) {
  131. uni.showToast({
  132. title: '操作成功',
  133. icon: 'success',
  134. duration: 2000
  135. })
  136. this.$emit('succeed')
  137. this.close()
  138. }
  139. })
  140. },
  141. // 选择图片
  142. async handlImageSelect (e) {
  143. let element = e.tempFiles[0]
  144. let url = await this.uploadFiles(element.path)
  145. console.log(url)
  146. if (url) {
  147. element.url = url
  148. this.form.repairsImg.push(element)
  149. }
  150. },
  151. // 图片删除
  152. handlImagDeletee (e) {
  153. let index = this.form.repairsImg.findIndex(n => {
  154. return n.uuid == e.tempFile.uuid
  155. })
  156. if (index !== -1) {
  157. this.form.repairsImg.splice(index, 1)
  158. }
  159. },
  160. // 文件上传
  161. uploadFiles (tempFilePaths) {
  162. let that = this
  163. return new Promise((resolve, reject) => {
  164. uni.uploadFile({
  165. url: this.apiUrl + '/data/doc/add', //后端用于处理图片并返回图片地址的接口
  166. filePath: tempFilePaths,
  167. name: 'file',
  168. header: that.header,
  169. formData: {
  170. module: '盘点'
  171. },
  172. success: res => {
  173. let data = JSON.parse(res.data) //返回的是字符串,需要转成对象格式
  174. resolve(data.data.accessUrl)
  175. },
  176. fail: err => {
  177. reject(null)
  178. uni.showToast({
  179. title: '图片上传失败',
  180. icon: 'none'
  181. })
  182. }
  183. })
  184. })
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .select-container {
  191. min-height: 60vh;
  192. }
  193. .fixed-bottom {
  194. background-color: #fff;
  195. width: 100%;
  196. /* position: fixed;
  197. left: 0;
  198. bottom: 0; */
  199. padding: 30rpx;
  200. box-sizing: border-box;
  201. }
  202. .sc-wrap {
  203. .title {
  204. margin-bottom: 7px;
  205. font-size: 32rpx;
  206. }
  207. margin-top: 15px;
  208. }
  209. .btn-wrap {
  210. margin-top: 30rpx;
  211. .qr-btn {
  212. background-color: #70b603f3;
  213. }
  214. .qx-btn {
  215. background-color: transparent;
  216. color: #555555;
  217. margin-top: 20rpx;
  218. }
  219. }
  220. .textarea {
  221. border: 1px solid #f2f2f2;
  222. width: 100%;
  223. margin-top: 20rpx;
  224. box-sizing: border-box;
  225. }
  226. .state-wrap {
  227. display: flex;
  228. align-items: center;
  229. .label {
  230. font-size: 28rpx;
  231. }
  232. .value-wrap {
  233. display: flex;
  234. }
  235. }
  236. .bt {
  237. color: #ff4949;
  238. }
  239. </style>