accessoryList.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="scheme">
  3. <u-list class="listContent">
  4. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  5. <myCard :item="item" @del="del(index)" @edit="add('edit',item,index)" :index="index+1"
  6. :columns="columns" :btnList="btnList">
  7. <u--input placeholder="请输入" type="number" @input="(val) =>inputChange(val,'totalCount',index)"
  8. slot="totalCount" v-model="item.totalCount">
  9. </u--input>
  10. <u--input placeholder="请输入" type="number" @input="(val) =>inputChange(val,'singlePrice',index)"
  11. slot="singlePrice" v-model="item.singlePrice">
  12. </u--input>
  13. </myCard>
  14. </view>
  15. </u-list>
  16. <view class="add" @click="add('add')" v-if="type != 'view'">
  17. <u-icon name="plus" color="#fff"></u-icon>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import myCard from '@/pages/saleManage/components/myCard.vue';
  23. import {
  24. getWarehouseOutStock,
  25. getIdWarehouseList
  26. } from '@/api/salesServiceManagement/workOrder/index.js';
  27. export default {
  28. components: {
  29. myCard
  30. },
  31. props: {
  32. type: {
  33. type: String,
  34. default: 'edit'
  35. },
  36. itemList: {
  37. type: Array,
  38. default: () => []
  39. },
  40. title: {
  41. type: String,
  42. default: ''
  43. }
  44. },
  45. watch: {
  46. itemList: {
  47. handler(newVal) {
  48. let list = JSON.parse(JSON.stringify(newVal));
  49. this.tableList = list;
  50. },
  51. deep: true,
  52. immediate: true
  53. }
  54. },
  55. data() {
  56. return {
  57. columns: [
  58. [{
  59. label: '物品名称:',
  60. prop: 'categoryName',
  61. type: 'title',
  62. className: 'perce100',
  63. }],
  64. [{
  65. label: '物品编码:',
  66. prop: 'categoryCode'
  67. }],
  68. [{
  69. label: '型号:',
  70. prop: 'categoryModel'
  71. }, {
  72. label: '规格:',
  73. prop: 'specification',
  74. }],
  75. [{
  76. label: '级别:',
  77. prop: 'level',
  78. }],
  79. [{
  80. label: '数量:',
  81. prop: 'totalCount',
  82. slot: 'totalCount',
  83. }],
  84. [{
  85. label: '单价:',
  86. prop: 'singlePrice',
  87. slot: 'singlePrice',
  88. }],
  89. [{
  90. label: '总价:',
  91. prop: 'totalPrice'
  92. }],
  93. [{
  94. label: '计量单位:',
  95. prop: 'measureUnit'
  96. }],
  97. [{
  98. label: '仓库:',
  99. prop: 'warehouseName'
  100. }],
  101. [{
  102. label: '操作:',
  103. prop: 'action',
  104. type: 'action',
  105. className: 'perce100',
  106. }],
  107. ],
  108. btnList: [{
  109. name: '删除',
  110. apiName: 'del',
  111. btnType: 'primary',
  112. type: '2',
  113. pageUrl: '',
  114. }],
  115. tableList: []
  116. }
  117. },
  118. computed: {},
  119. created() {
  120. uni.$off('updateAddessory');
  121. uni.$on('updateAddessory', (data) => {
  122. let obj = {}
  123. this.tableList.map((el) => obj[el] = true);
  124. data.map((el) => {
  125. if (!obj[el.id]) {
  126. this.tableList.push(el);
  127. }
  128. })
  129. })
  130. },
  131. onShow() {
  132. },
  133. methods: {
  134. add() {
  135. let dataSources = this.title == '配件回收清单' ? '1' : '0';
  136. uni.navigateTo({
  137. url: `/pages/salesServiceManagement/workOrder/components/accessoryAdd?dataSources=${dataSources}`
  138. })
  139. },
  140. del(index) {
  141. uni.showModal({
  142. title: '确认删除',
  143. content: '确定要删除所选配件数据吗?',
  144. confirmText: '删除',
  145. confirmColor: '#FF4D4F',
  146. success: (res) => {
  147. if (res.confirm) {
  148. this.tableList.splice(index, 1)
  149. } else if (res.cancel) {
  150. // 用户点击了取消按钮
  151. console.log('用户取消删除');
  152. }
  153. }
  154. });
  155. },
  156. inputChange(e, field, index) {
  157. let value = '';
  158. if (field == 'singlePrice') {
  159. value = e.replace(/[^\d.]/g, '');
  160. const parts = value.split('.');
  161. if (parts.length > 2) {
  162. value = parts[0] + '.' + parts.slice(1).join('');
  163. }
  164. if (value.startsWith('0') && value.length > 1 && value[1] !== '.') {
  165. value = value.replace(/^0+/, '');
  166. }
  167. } else {
  168. value = e.replace(/[^\d]/g, '')
  169. if (value.startsWith('0') && value.length > 1) {
  170. value = value.replace(/^0+/, '');
  171. }
  172. }
  173. let obj = this.tableList[index];
  174. obj[field] = value;
  175. let num1 = obj.totalCount ? obj.totalCount - 0 : 0;
  176. let num2 = obj.singlePrice ? obj.singlePrice - 0 : 0;
  177. let total = (num1 * num2).toFixed(1);
  178. obj.totalPrice = total;
  179. },
  180. getTabData() {
  181. return this.tableList || [];
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  188. .scheme {
  189. padding: 10rpx 20rpx 88rpx;
  190. }
  191. .add {
  192. width: 96rpx;
  193. height: 96rpx;
  194. border-radius: 48rpx;
  195. background: #3c9cff;
  196. position: fixed;
  197. bottom: 100rpx;
  198. right: 24rpx;
  199. display: flex;
  200. align-items: center;
  201. justify-content: center;
  202. }
  203. </style>