edit.vue 9.0 KB

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