accessoryAdd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" @clickLeft="back">
  4. <template slot="right">
  5. <u-button type="success" size="small" class="u-reset-button" @click="classification"
  6. text="选择分类"></u-button>
  7. </template>
  8. </uni-nav-bar>
  9. <view class="top-wrapper">
  10. <uni-section class="dimension" v-if="dataSources == '0'">
  11. <uni-data-select @change="(e)=>onchange(e)" v-model="dimension" :clear="false"
  12. :localdata="dimensionList">
  13. </uni-data-select>
  14. </uni-section>
  15. <uni-section v-if="dataSources == '1'">
  16. <uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="searchKey" placeholder="关键字">
  17. </uni-easyinput>
  18. </uni-section>
  19. <button class="search_btn" @click="getData({})">搜索</button>
  20. <image class="menu_icon" @click="handleSearch" src="~@/static/pda/menu.svg"></image>
  21. </view>
  22. <!-- <view class="nav_box rx-sc">
  23. <view class="nav_item " :class="{active: current == 0}" @click="handNav(0)">
  24. 库存台账</view>
  25. <view class="nav_item" :class="{active: current == 1}" @click="handNav(1)">
  26. 主数据</view>
  27. <view class="add btn" v-show="current == 0" @click="add">
  28. 添加
  29. </view>
  30. <view class="remove btn" v-show="current == 1" @click="remove">
  31. 移除
  32. </view>
  33. </view> -->
  34. <view class="wrapper">
  35. <!-- v-show="current == 0" -->
  36. <u-list @scrolltolower="scrolltolower" class="listContent">
  37. <checkbox-group v-for="(item, index) in accessoriesList" :key="index"
  38. @change="e => selectVal(e, item, index)">
  39. <label>
  40. <view class="listBox">
  41. <view class="listBox-sel">
  42. <checkbox :value="item.id" color="#fff" :disabled="item.disabled"
  43. :checked="item.checked" />
  44. </view>
  45. <view class="listBox-con">
  46. <view class="listBox-bottom">
  47. <view>
  48. <text>{{!fieldShow?'编码':'物品编码'}}:</text>
  49. <text class="value">{{ item.code }}</text>
  50. </view>
  51. <view>
  52. <text>{{!fieldShow?'名称':'物品名称'}}:</text>
  53. <text class="value">{{ item.name }}</text>
  54. </view>
  55. <view class="label-s">
  56. <text>牌号:</text>
  57. <text class="value">{{ item.brandNum }}</text>
  58. </view>
  59. <view class="label-s">
  60. <text>型号:</text>
  61. <text class="value">{{ item.categoryModel }}</text>
  62. </view>
  63. <view>
  64. <text>规格:</text>
  65. <text class="value">{{ item.specification }}</text>
  66. </view>
  67. <view class="label-s" v-if="dimension == 3">
  68. <text>批次号:</text>
  69. <text class="value">{{ item.batchNo }}</text>
  70. </view>
  71. <view class="label-s">
  72. <text>级别:</text>
  73. <text class="value">{{ item.level }}</text>
  74. </view>
  75. <view class="label-s" v-if="fieldShow">
  76. <text>计量数量:</text>
  77. <text class="value">{{ item.measureQuantity }}</text>
  78. </view>
  79. <view class="label-s" v-if="fieldShow">
  80. <text>计量单位:</text>
  81. <text class="value">{{ item.measureUnit }}</text>
  82. </view>
  83. <view class="label-s">
  84. <text>重量:</text>
  85. <text class="value">{{ item.weight }}</text>
  86. </view>
  87. <view class="label-s">
  88. <text>重量单位:</text>
  89. <text class="value">{{ item.weightUnit }}</text>
  90. </view>
  91. <view v-if="dimension == 3">
  92. <text>包装编码:</text>
  93. <text class="value">{{ item.packageNo }}</text>
  94. </view>
  95. <view class="label-s" v-if="dimension == 3">
  96. <text>包装数量:</text>
  97. <text class="value">{{ item.packingQuantity }}</text>
  98. </view>
  99. <view class="label-s" v-if="dimension == 3">
  100. <text>包装单位:</text>
  101. <text class="value">{{ item.packingUnit }}</text>
  102. </view>
  103. <view v-if="dimension == 3 || dimension == 4">
  104. <text>发货条码:</text>
  105. <text class="value">{{ item.barcodes }}</text>
  106. </view>
  107. <view v-if="dimension == 4">
  108. <text>物料编码:</text>
  109. <text class="value">{{ item.no }}</text>
  110. </view>
  111. <view v-if="dimension == 3 || dimension == 4">
  112. <text>物料代号:</text>
  113. <text class="value">{{ item.materielDesignation }}</text>
  114. </view>
  115. <view v-if="dimension == 3 || dimension == 4">
  116. <text>客户代号:</text>
  117. <text class="value">{{ item.clientCode }}</text>
  118. </view>
  119. <view v-if="dimension == 3 || dimension == 4">
  120. <text>刻码:</text>
  121. <text class="value">{{ item.engrave }}</text>
  122. </view>
  123. <view v-if="dimension == 3 || dimension == 4">
  124. <text>仓库:</text>
  125. <text class="value">{{ item.warehouseName }}</text>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </label>
  131. </checkbox-group>
  132. <u-empty class="noDate" style="margin-top: 20vh" v-if="!accessoriesList.length"></u-empty>
  133. </u-list>
  134. <!-- <u-list class="listContent" v-show="current == 1">
  135. <checkbox-group v-for="(item, index) in addList" :key="index"
  136. @change="e => selectAddVal(e, item, index)">
  137. <label>
  138. <view class="listBox">
  139. <view class="listBox-sel">
  140. <checkbox :value="item.id" color="#fff" :checked="item.checked" />
  141. </view>
  142. <view class="listBox-con">
  143. <view class="listBox-bottom">
  144. <view>{{!fieldShow ? '编码' : '物品编码'}}:{{ item.categoryCode }}</view>
  145. <view>{{!fieldShow ? '名称' : '物品名称'}}:{{ item.categoryName }}</view>
  146. <view>型号:{{ item.categoryModel }}</view>
  147. <view>规格:{{ item.specification }}</view>
  148. <view class="label-s">级别:{{ item.level }}</view>
  149. <view class="label-s">库存:{{ item.measureQuantity }}</view>
  150. <view v-if="dataSources == '0'">计量单位:{{ item.measureUnit }}</view>
  151. <view>仓库:{{ item.warehouseName }}</view>
  152. </view>
  153. </view>
  154. </view>
  155. </label>
  156. </checkbox-group>
  157. <u-empty class="noDate" style="margin-top: 20vh" v-if="!addList.length"></u-empty>
  158. </u-list> -->
  159. </view>
  160. <view class="footer">
  161. <u-button type="success" size="small" class="u-reset-button" @click="jumpAdd">
  162. <view class="selBtn">选择({{ addList.length }})</view>
  163. </u-button>
  164. </view>
  165. <screenAccess :dataSources="dataSources" ref="screen" @succeed="getData" />
  166. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  167. :selectedData="selectedData" :localdata="classificationList" valueKey="id" textKey="name"
  168. childrenKey="children" />
  169. <u-toast ref="uToast"></u-toast>
  170. </view>
  171. </template>
  172. <script>
  173. import screenAccess from './screenAccess.vue'
  174. import {
  175. getProductList,
  176. getBatchDetails,
  177. getInventoryDetails,
  178. getMaterielDetails,
  179. } from '@/api/repair';
  180. import {
  181. treeByPid
  182. } from '@/api/pda/workOrder.js';
  183. import {
  184. getList
  185. } from '@/api/classifyManage/itemInformation.js'
  186. export default {
  187. components: {
  188. screenAccess
  189. },
  190. data() {
  191. return {
  192. title: '新增配件',
  193. dataSources: '0', // 0 仓库 1 主数据
  194. accessoriesList: [], // 配件列表
  195. addList: [], // 添加列表
  196. classificationList: [],
  197. categoryLevelId: 6, // 分类id(默认6 查询备品备件)
  198. selectedData: ['6'],
  199. isEnd: false,
  200. pageNum: 1,
  201. dimensionList: [{
  202. value: '4',
  203. text: '物料维度'
  204. },
  205. {
  206. value: '3',
  207. text: '包装维度'
  208. },
  209. {
  210. value: '2',
  211. text: '批次维度'
  212. },
  213. {
  214. value: '1',
  215. text: '物品维度'
  216. },
  217. ],
  218. dimension: '1', // 列表维度
  219. current: 0,
  220. searchKey: ''
  221. }
  222. },
  223. onLoad(params) {
  224. this.dataSources = params.dataSources || '0';
  225. },
  226. computed: {
  227. // 物品字段
  228. fieldShow() {
  229. return this.dataSources == '0';
  230. },
  231. },
  232. onShow() {
  233. this.getTreeList();
  234. },
  235. methods: {
  236. handleSearch() {
  237. this.$refs.screen.open();
  238. },
  239. confirm(id, name) {
  240. this.categoryLevelId = id;
  241. this.accessoriesList = [];
  242. this.getData();
  243. },
  244. onchange(e) {
  245. this.dimension = e;
  246. this.getData({});
  247. },
  248. // 获取页面数据
  249. getData(parameter = {}) {
  250. let data = parameter;
  251. if (!data.scroll) {
  252. this.isEnd = false;
  253. this.pageNum = 1;
  254. this.accessoriesList = [];
  255. } else {
  256. delete data.scroll;
  257. }
  258. if (this.dataSources == '0') {
  259. this.changeDimension(this.dimension, data);
  260. } else {
  261. let obj = this.$refs.screen.mainForm;
  262. // 查询主数据
  263. this.warehouseData(obj);
  264. }
  265. },
  266. // 主数据
  267. warehouseData(data = {}) {
  268. let form = {
  269. ...data,
  270. searchKey: this.searchKey,
  271. pageNum: this.pageNum,
  272. size: 15,
  273. categoryLevelId: this.categoryLevelId
  274. }
  275. uni.showLoading({
  276. title: '加载中'
  277. })
  278. getList(form).then((res) => {
  279. let list = res.list.map((el) => {
  280. el.categoryModel = el.modelType;
  281. el.categoryName = el.name;
  282. el.categoryCode = el.code;
  283. return el;
  284. });
  285. if (this.pageNum == 1) {
  286. this.accessoriesList = list;
  287. } else {
  288. this.accessoriesList.push(...list);
  289. }
  290. this.pageNum += 1
  291. this.isEnd = this.accessoriesList.length >= res.count;
  292. uni.hideLoading();
  293. }).then((e) => {
  294. uni.hideLoading();
  295. })
  296. },
  297. // 仓库数据
  298. changeDimension(dimension, parameter = {}) {
  299. if (this.isEnd) {
  300. return
  301. }
  302. uni.showLoading({
  303. title: '加载中'
  304. })
  305. return new Promise(async (resolve, reject) => {
  306. try {
  307. let params = {
  308. // assetName: this.assetName,
  309. // dimension: this.dimension,
  310. ...parameter,
  311. pageNum: this.pageNum,
  312. size: 15,
  313. categoryLevelId: this.categoryLevelId
  314. }
  315. const api = dimension == 1 ? getProductList : dimension == 2 ?
  316. getBatchDetails : dimension == 3 ? getInventoryDetails : getMaterielDetails;
  317. let res = await api(params);
  318. let list = res.list.map((el) => {
  319. el.modelType = el.categoryModel;
  320. el.name = el.categoryName;
  321. el.code = el.categoryCode;
  322. return el;
  323. });
  324. if (this.pageNum == 1) {
  325. this.accessoriesList = list;
  326. } else {
  327. this.accessoriesList.push(...list);
  328. }
  329. this.pageNum += 1
  330. this.isEnd = this.accessoriesList.length >= res.count;
  331. uni.hideLoading();
  332. resolve();
  333. } catch (error) {
  334. uni.hideLoading();
  335. reject();
  336. }
  337. })
  338. },
  339. scrolltolower() {
  340. if (this.isEnd) {
  341. return;
  342. }
  343. this.getData({
  344. scroll: true
  345. });
  346. },
  347. classification() {
  348. this.$refs.treePicker._show();
  349. },
  350. // 查部门
  351. getTreeList() {
  352. treeByPid({
  353. ids: [6]
  354. }).then(res => {
  355. this.classificationList = res;
  356. this.confirm(res[0].id, res[0].name);
  357. })
  358. },
  359. handNav(index) {
  360. this.current = index;
  361. },
  362. // remove() {
  363. // this.addList = this.addList.filter(item => !item.checked);
  364. // },
  365. // add() {
  366. // let checkedList = this.accessoriesList.filter(item => item.checked);
  367. // if (checkedList.length == 0) {
  368. // this.$refs.uToast.show({
  369. // type: "warning",
  370. // message: "请至少选择一条配件数据",
  371. // })
  372. // }
  373. // let obj = {};
  374. // this.addList.map(el => {
  375. // obj[el.id] = true;
  376. // })
  377. // checkedList.map((el) => {
  378. // if (!obj[el.id]) {
  379. // let data = JSON.parse(JSON.stringify(el));
  380. // delete data.checked;
  381. // this.addList.push(data);
  382. // }
  383. // })
  384. // this.current = 1;
  385. // },
  386. // 选择配件列表
  387. selectVal(e, val, index) {
  388. this.$set(this.accessoriesList[index], 'checked', !this.accessoriesList[index].checked);
  389. this.addList = this.accessoriesList.filter(item => item.checked)
  390. },
  391. // selectAddVal(e, val, index) {
  392. // this.$set(this.addList[index], 'checked', !this.addList[index].checked);
  393. // },
  394. jumpAdd() {
  395. let list = JSON.parse(JSON.stringify(this.addList));
  396. if (list.length == 0) {
  397. this.$refs.uToast.show({
  398. type: "warning",
  399. message: "请至少添加一条物品数据",
  400. })
  401. return;
  402. }
  403. list.forEach((el) => delete el.checked);
  404. uni.$emit('updateAddessory', list);
  405. this.back();
  406. }
  407. }
  408. }
  409. </script>
  410. <style scoped lang="scss">
  411. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  412. @import './accessory.scss';
  413. </style>