DialogTagApplyDetail.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <el-dialog
  3. :visible.sync="visible"
  4. :title="`订单详情 ${oData && oData.orderNo ? oData.orderNo : ''}`"
  5. append-to-body
  6. width="1200px"
  7. >
  8. <div class="flex column" style="padding-bottom:20px;height:580px">
  9. <div class="flex valign-center">
  10. <el-button
  11. plain
  12. icon="el-icon-delete"
  13. type="primary"
  14. size="small"
  15. class="custom-plain-button"
  16. @click="onBatchDeleteBtnClick"
  17. :disabled="selectedList.length === 0 || (oData.tagApplyStateId !='0' && oData.tagApplyStateId != '1')"
  18. >批量删除</el-button>
  19. </div>
  20. <div class="flex-1 fit-size" style="padding-top:20px;">
  21. <el-table
  22. ref="table"
  23. :data="list"
  24. stripe
  25. border
  26. height="100%"
  27. size="small"
  28. class="custom-el-table-style"
  29. @selection-change="onSelectionChange"
  30. @row-click="onRowClick"
  31. >
  32. <el-table-column
  33. type="selection"
  34. width="55"
  35. align="center"
  36. :selectable="tagSelectAble"
  37. fixed
  38. ></el-table-column>
  39. <el-table-column
  40. type="index"
  41. label="序号"
  42. width="60"
  43. align="center"
  44. fixed
  45. ></el-table-column>
  46. <el-table-column
  47. label="商品编码"
  48. prop="goodsCode"
  49. header-align="center"
  50. min-width="100"
  51. align="center"
  52. ></el-table-column>
  53. <el-table-column
  54. label="商品名称"
  55. min-width="200"
  56. prop="goodsName"
  57. header-align="center"
  58. align="center"
  59. ></el-table-column>
  60. <el-table-column
  61. label="物料编码"
  62. min-width="100"
  63. prop="materielCode"
  64. header-align="center"
  65. align="center"
  66. ></el-table-column>
  67. <el-table-column
  68. label="最小包装数量"
  69. min-width="80"
  70. prop="minimumPackingNumber"
  71. header-align="center"
  72. align="center"
  73. ></el-table-column>
  74. <el-table-column
  75. label="最小包装单位"
  76. min-width="80"
  77. prop="minimumPackingUnit"
  78. header-align="center"
  79. align="center"
  80. ></el-table-column>
  81. <el-table-column
  82. label="数量"
  83. min-width="80"
  84. prop="number"
  85. header-align="center"
  86. align="center"
  87. >
  88. <template slot-scope="scope">
  89. <el-input v-model="scope.row.number" :class="{ 'input-error': scope.row.number === '' }" @input="handleInput" :disabled="oData.tagApplyStateId !='0' && oData.tagApplyStateId != '1'"></el-input>
  90. </template>
  91. </el-table-column>
  92. <el-table-column
  93. label="单价(元)"
  94. prop="unitPrice"
  95. align="right"
  96. min-width="70"
  97. header-align="center"
  98. ></el-table-column>
  99. <el-table-column
  100. label="费用(元)"
  101. prop="amount"
  102. align="right"
  103. min-width="70"
  104. header-align="center"
  105. ></el-table-column>
  106. <el-table-column
  107. label="标签类型"
  108. prop="tagTypeName"
  109. align="left"
  110. min-width="120"
  111. header-align="center"
  112. ></el-table-column>
  113. <el-table-column
  114. label="操作栏"
  115. min-width="80"
  116. header-align="center"
  117. align="center"
  118. >
  119. <template v-slot="{ row }">
  120. <div class="flex center layout-gap">
  121. <edit-button :data="row" :on-click="onDeleteBtnClick" icon="el-icon-delete" :disabled="oData.tagApplyStateId !='0' && oData.tagApplyStateId != '1'">删除</edit-button>
  122. </div>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. </div>
  127. </div>
  128. <template #footer v-if="oData && (oData.tagApplyStateId === '0'||oData.tagApplyStateId === '1')">
  129. <div class="flex center dialog-footer">
  130. <el-button
  131. @click="onCloseBtnClick"
  132. >取消</el-button>
  133. <el-button
  134. type="primary"
  135. @click="onOkBtnClick"
  136. >确定</el-button>
  137. </div>
  138. </template>
  139. </el-dialog>
  140. </template>
  141. <script>
  142. import BaseCurdList from '@@/utils/BaseCurdList'
  143. import TagApply from '@@/entries/TagApply'
  144. export default {
  145. name: 'DialogTagApplyDetail',
  146. extends: BaseCurdList(TagApply),
  147. props: {
  148. api: {
  149. required: true,
  150. type: Function
  151. }
  152. },
  153. data: () => ({
  154. visible: false,
  155. oData: null
  156. }),
  157. methods: {
  158. open (data) {
  159. this.oData = data
  160. this.visible = true
  161. this.list = data.details
  162. },
  163. close () {
  164. this.oData = null
  165. this.visible = false
  166. this.list = Object.freeze([])
  167. },
  168. tagSelectAble () {
  169. return this.oData.tagApplyStateId === '0' || this.oData.tagApplyStateId === '1'
  170. },
  171. onBatchDeleteBtnClick () {
  172. const { selectedList } = this
  173. this.$confirm(`此操作将删除选中的记录, 是否继续?`, '确认', {
  174. confirmButtonText: '确定',
  175. cancelButtonText: '取消',
  176. confirmButtonClass: 'confirm-dialog-confirm-btn',
  177. cancelButtonClass: 'confirm-dialog-cancel-btn',
  178. type: 'warning'
  179. }).then(() => {
  180. const ids = new Set(selectedList.map(data => data.id))
  181. this.list = this.list.filter(item => !ids.has(item.id))
  182. this.oData.details = this.list
  183. }).catch(() => {})
  184. },
  185. onDeleteBtnClick (data) {
  186. this.$confirm(`此操作将删除该记录, 是否继续?`, '确认', {
  187. confirmButtonText: '确定',
  188. cancelButtonText: '取消',
  189. confirmButtonClass: 'confirm-dialog-confirm-btn',
  190. cancelButtonClass: 'confirm-dialog-cancel-btn',
  191. type: 'warning'
  192. }).then(() => {
  193. this.list = this.list.filter(item => item.id !== data.id)
  194. this.oData.details = this.list
  195. }).catch(() => {})
  196. },
  197. onCloseBtnClick () {
  198. this.close()
  199. },
  200. onOkBtnClick () {
  201. this.$$request(this.api, this.oData).then(() => {
  202. this.close()
  203. this.$emit('saved')
  204. }).catch(console.error).finally(() => {})
  205. },
  206. handleInput (value) {
  207. let sanitizedValue = value.replace(/[^0-9]/g, '')
  208. sanitizedValue = sanitizedValue.replace(/^0+/, '')
  209. this.selectedData.number = sanitizedValue === '' ? '' : sanitizedValue
  210. this.selectedData.amount = sanitizedValue === '' ? 0 : (sanitizedValue * this.selectedData.unitPrice).toFixed(2)
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss">
  216. .input-error .el-input__inner {
  217. border-color: red;
  218. }
  219. </style>