edit.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="新增报损报溢" @clickLeft="back"></uni-nav-bar>
  4. <u-form labelPosition="left" :model="formData" :rules="rules" ref="formRef" labelWidth="240" labelAlign="right"
  5. class="baseForm">
  6. <u-form-item label="报损报溢编码" borderBottom prop="code">
  7. <u-input :value="formData.code" disableColor="#ffffff" placeholder="请选择" disabled type="select" />
  8. </u-form-item>
  9. <u-form-item label="名称" class="required-form" borderBottom prop="name">
  10. <u-input v-model="formData.name" placeholder="请输入" type="text" />
  11. </u-form-item>
  12. <u-form-item label="报损报溢部门" class="required-form" prop="bizScene" borderBottom>
  13. <u-input v-model="formData.executeGroupName" disableColor="#ffffff"
  14. @click.native="$refs.treePicker._show()" placeholder="请选择" type="select" />
  15. </u-form-item>
  16. <u-form-item label="报损报溢人" class="required-form" prop="reportName" borderBottom>
  17. <uni-data-select v-model="formData.executorId" :localdata="userList"
  18. @change="userChange"></uni-data-select>
  19. </u-form-item>
  20. <u-form-item label="备注" prop="remark" borderBottom>
  21. <u-input v-model="formData.remark" placeholder="请输入" type="text" />
  22. </u-form-item>
  23. </u-form>
  24. <uni-section title="报损报溢明细" type="line">
  25. <template v-slot:right>
  26. <text class="text-primary" @click="workorderSelect">选择盘点工单</text>
  27. </template>
  28. <view class="order-box">盘点工单{{ formData.workOrderCode }}</view>
  29. <view v-for="(item, index) in formData.list" :key="index" class="list-card">
  30. <view class="status" :style="{ color: colorInfo[item.status] }">
  31. <text>{{ statusInfo[item.status] }}</text>
  32. <text>数量:{{ item[countInfo[item.status]] }}</text>
  33. </view>
  34. <view class="row first">
  35. <view class="col" style="width: 100%">
  36. <text class="main">{{ item.categoryName }}</text>
  37. {{ item.categoryCode }}
  38. </view>
  39. <view class="col" style="width: 100%">
  40. <text class="main">包装编码:</text>
  41. {{ item.packageNo }}
  42. </view>
  43. <view class="col" style="width: 100%">
  44. <text class="main">仓库:</text>
  45. {{ item.info.warehouseName }}
  46. </view>
  47. </view>
  48. <view class="row">
  49. <view class="col">
  50. <text class="label">包装数量:</text>
  51. {{ item.info.packingCountBase }}
  52. </view>
  53. <view class="col">
  54. <text class="label">包装单位:</text>
  55. {{ item.info.packingUnit }}
  56. </view>
  57. <view class="col">
  58. <text class="label">重量:</text>
  59. {{ item.info.weight }}
  60. </view>
  61. <view class="col">
  62. <text class="label">重量单位:</text>
  63. {{ item.info.weightUnit }}
  64. </view>
  65. <view class="col">
  66. <text class="label">批次号:</text>
  67. {{ item.batchNo }}
  68. </view>
  69. </view>
  70. </view>
  71. </uni-section>
  72. <view class="footBox">
  73. <u-button type="success" @click="handleSubmit">提交</u-button>
  74. </view>
  75. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="deptConfirm" title="选择部门"
  76. :localdata="listData" valueKey="id" textKey="name" childrenKey="children" />
  77. </view>
  78. </template>
  79. <script>
  80. import {
  81. getCode,
  82. saveReportsList
  83. } from '@/api/warehouseManagement'
  84. import {
  85. listOrganizations,
  86. getUserPage
  87. } from '@/api/myTicket/index.js'
  88. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  89. import {
  90. getRuleNo
  91. } from '@/utils/utils.js'
  92. // import dictMxins from '@/mixins/dictMixins'
  93. export default {
  94. components: {
  95. baTreePicker
  96. },
  97. // mixins: [dictMxins],
  98. data() {
  99. return {
  100. listData: [],
  101. statusInfo: {
  102. 2: '盘盈',
  103. 3: '丢失',
  104. 4: '破损'
  105. },
  106. countInfo: {
  107. 2: 'surplusQuantity',
  108. 3: 'loseQuantity',
  109. 4: 'wornQuantity'
  110. },
  111. colorInfo: {
  112. 2: 'red',
  113. 3: 'green',
  114. 4: 'black'
  115. },
  116. statusOption: [{
  117. label: '盘盈',
  118. value: '2',
  119. numKey: 'surplusQuantity'
  120. },
  121. {
  122. label: '丢失',
  123. value: '3',
  124. numKey: 'loseQuantity'
  125. },
  126. {
  127. label: '破损',
  128. value: '4',
  129. numKey: 'wornQuantity'
  130. }
  131. ],
  132. pickerIndex: 0,
  133. deptList: [],
  134. userList: [],
  135. formData: {
  136. code: '',
  137. name: '',
  138. executeGroupName: '',
  139. executeGroupId: '',
  140. executorName: '',
  141. executorId: '',
  142. workOrderCode: '',
  143. list: []
  144. },
  145. isMaterial: true,
  146. rules: {
  147. // name: {
  148. // type: 'string',
  149. // required: true,
  150. // message: '请输入名称',
  151. // trigger: ['blur']
  152. // }
  153. }
  154. }
  155. },
  156. onLoad({
  157. id
  158. }) {
  159. // this.requestDict('物品类型')
  160. if (id) {
  161. this.getDetail(id)
  162. } else {
  163. const userInfo = uni.getStorageSync('userInfo')
  164. console.log(userInfo)
  165. }
  166. this.getDept()
  167. this.getOrderCode()
  168. uni.$off('getWorkorder')
  169. uni.$on('getWorkorder', data => {
  170. console.log(data)
  171. if (data?.id) {
  172. this.formData.workOrderCode = data.code
  173. this.formData.list = data.planDetailVOList
  174. this.formData.tableList = [data]
  175. }
  176. })
  177. },
  178. methods: {
  179. userChange(value) {
  180. this.formData.executorId = value
  181. this.formData.executorName = this.userList.find(item => item.value == value).text
  182. },
  183. async getOrderCode() {
  184. const code = await getCode('plan_profit_loss')
  185. this.formData.code = code
  186. },
  187. workorderSelect() {
  188. uni.navigateTo({
  189. url: '/pages/warehouse/reportLoss/workorderSelected'
  190. })
  191. },
  192. async getDetail(id) {},
  193. async handleSubmit() {
  194. if (!this.formData.name) {
  195. uni.showToast({
  196. title: '请输入名称!',
  197. icon: 'none'
  198. })
  199. return
  200. }
  201. if (!this.formData.executeGroupId) {
  202. uni.showToast({
  203. title: '请选择部门!',
  204. icon: 'none'
  205. })
  206. return
  207. }
  208. if (!this.formData.executorId) {
  209. uni.showToast({
  210. title: '请选择人员!',
  211. icon: 'none'
  212. })
  213. return
  214. }
  215. if (!this.formData.list?.length) {
  216. uni.showToast({
  217. title: '请选择工单!',
  218. icon: 'none'
  219. })
  220. return
  221. }
  222. let params = {
  223. ...this.formData,
  224. info: this.formData.tableList,
  225. status: 1
  226. }
  227. uni.showLoading({
  228. title: '加载中'
  229. })
  230. saveReportsList(params)
  231. .then(() => {
  232. uni.hideLoading()
  233. uni.showToast({
  234. title: '提交成功!',
  235. icon: 'success'
  236. })
  237. uni.navigateTo({
  238. url: `/pages/warehouse/reportLoss/index`
  239. })
  240. })
  241. .catch(() => {
  242. uni.hideLoading()
  243. })
  244. },
  245. // 部门确认
  246. deptConfirm(data, name) {
  247. this.formData.executeGroupId = data[0]
  248. this.formData.executeGroupName = name
  249. this.formData.executorId = ''
  250. this.formData.executorName = ''
  251. this.getUser(data[0])
  252. },
  253. // 获取部门
  254. getDept() {
  255. listOrganizations(1).then(data => {
  256. this.listData = data
  257. })
  258. },
  259. // 获取人员
  260. getUser(deptCode) {
  261. uni.showLoading({
  262. title: '加载中'
  263. })
  264. getUserPage({
  265. pageNum: 1,
  266. size: -1,
  267. groupId: deptCode
  268. })
  269. .then(data => {
  270. this.userList = data.list.map(item => {
  271. item.text = item.name
  272. item.value = item.id
  273. return item
  274. })
  275. })
  276. .finally(() => {
  277. uni.hideLoading()
  278. })
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss" scoped>
  284. .footBox {
  285. position: fixed;
  286. bottom: 0;
  287. left: 0;
  288. right: 0;
  289. }
  290. .mainBox {
  291. /deep/.baseForm {
  292. .u-form-item__body {
  293. padding: 4px !important;
  294. }
  295. .assetType_box {
  296. padding: 12rpx 18rpx;
  297. width: 100%;
  298. overflow: hidden;
  299. white-space: nowrap;
  300. text-overflow: ellipsis;
  301. font-size: 30rpx;
  302. }
  303. }
  304. padding-bottom: 90rpx;
  305. /deep/.required-form .u-form-item__body__left__content__label::before {
  306. content: '*';
  307. color: red;
  308. }
  309. .select_user {
  310. width: 100%;
  311. padding: 12rpx 20rpx;
  312. box-sizing: border-box;
  313. /deep/ .uni-select {
  314. height: 48rpx;
  315. }
  316. }
  317. .order-box {
  318. color: #7f7f7f;
  319. background-color: rgba(215, 215, 215, 0.729411764705882);
  320. line-height: 66rpx;
  321. border-radius: 44rpx;
  322. text-align: center;
  323. font-size: 28rpx;
  324. margin: 0 20rpx;
  325. }
  326. .list-card {
  327. border-bottom: 20rpx solid #f2f2f2;
  328. position: relative;
  329. .status {
  330. padding: 16rpx 32rpx;
  331. font-weight: bold;
  332. font-size: 28rpx;
  333. display: flex;
  334. justify-content: space-between;
  335. align-items: center;
  336. border-bottom: 1rpx solid #f2f2f2;
  337. }
  338. .del {
  339. position: absolute;
  340. color: $uni-color-order-error !important;
  341. bottom: 5rpx;
  342. right: 10rpx;
  343. font-size: 50rpx !important;
  344. }
  345. .row {
  346. display: flex;
  347. justify-content: flex-start;
  348. align-items: center;
  349. flex-wrap: wrap;
  350. font-size: 28rpx;
  351. padding: 10rpx 20rpx;
  352. // color: #7d7d7d;
  353. &.first {
  354. // color: #000;
  355. font-size: 28rpx;
  356. border-bottom: 1rpx solid #f2f2f2;
  357. .col {
  358. min-width: 0%;
  359. }
  360. }
  361. .col {
  362. min-width: 50%;
  363. line-height: 24px;
  364. }
  365. .label {
  366. margin-right: 10rpx;
  367. display: inline-block;
  368. width: 180rpx;
  369. text-align: right;
  370. }
  371. .main {
  372. margin-right: 10rpx;
  373. }
  374. }
  375. }
  376. }
  377. </style>