add-price-declaration.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <!-- 价格申报单-新增 -->
  2. <template>
  3. <el-drawer title="我是标题" direction="btt" size="100%" :with-header="false" :visible.sync="visible"
  4. :before-close="handleClose">
  5. <el-card :body-style="{
  6. padding: '20px',
  7. display: 'flex',
  8. 'flex-wrap': 'wrap',
  9. }" style="margin: 10px">
  10. <div slot="header" style="
  11. display: flex;
  12. justify-content: space-between;
  13. align-items: center;
  14. ">
  15. <h3>新增</h3>
  16. <div style="text-align: right">
  17. <el-button size="mini" @click="setVisible(false)">取消</el-button>
  18. <el-button size="mini" type="info" @click="setVisible(false)">保存并新增</el-button>
  19. <el-button size="mini" type="danger" @click="setVisible(false)">保存</el-button>
  20. </div>
  21. </div>
  22. <el-row>
  23. <el-form size="mini" label-position="right" label-width="150px" :model="params">
  24. <el-col v-for="(column, index) in columns" :key="index" :span="column.span || 8">
  25. <el-form-item :prop="column.key" :label="column.title" :required="column.required">
  26. <el-input v-if="column.type === 'Input'" v-model="params[column.key]" :placeholder="column.placeholder"
  27. :clearable="column.clearable" style="width: 90%"></el-input>
  28. <el-input-number v-if="column.type === 'InputNumber'" v-model="params[column.key]"
  29. :controls-position="column.config.controlsPosition" :placeholder="column.placeholder"
  30. :clearable="column.clearable" style="width: 90%"></el-input-number>
  31. <el-select v-if="column.type === 'Select'" v-model="params[column.key]" :placeholder="column.placeholder"
  32. :clearable="column.clearable" style="width: 90%">
  33. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  34. </el-option>
  35. </el-select>
  36. <el-select v-if="column.type === 'TagSelect'" v-model="params[column.key]" multiple clearable collapse-tags
  37. :placeholder="column.placeholder" :clearable="column.clearable" style="width: 90%">
  38. <template #prefix>
  39. <el-icon class="el-icon-s-operation" style="cursor: pointer" @click.stop="$message.info(234)"></el-icon>
  40. </template>
  41. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  42. </el-option>
  43. </el-select>
  44. <el-date-picker v-if="column.type === 'DatePicker'" v-model="params[column.key]" :type="column.config.type"
  45. :placeholder="column.placeholder" :clearable="column.clearable" :picker-options="column.pickerOptions"
  46. style="width: 90%">
  47. </el-date-picker>
  48. <el-upload v-if="column.type === 'Upload'" :file-list="params[column.key]" drag
  49. action="https://jsonplaceholder.typicode.com/posts/" multiple>
  50. <i class="el-icon-upload"></i>
  51. <div class="el-upload__text">
  52. 将文件拖到此处,或<em>点击上传</em>
  53. </div>
  54. <div class="el-upload__tip" slot="tip">
  55. 只能上传jpg/png文件,且不超过500kb
  56. </div>
  57. </el-upload>
  58. </el-form-item>
  59. </el-col>
  60. </el-form>
  61. </el-row>
  62. </el-card>
  63. <el-card :body-style="{
  64. padding: '20px',
  65. display: 'flex',
  66. 'flex-wrap': 'wrap',
  67. }" style="margin: 10px">
  68. <el-tabs v-model="tabName" @tab-click="handleClick" style="width: 100%">
  69. <el-tab-pane v-for="(column, index) in tabColumns" :key="index" :label="column.title" :name="column.key">
  70. <el-table :data="tabTableDatas[column.key]" style="width: 100%">
  71. <el-table-column v-for="(cColumn, cIndex) in column.tableColumns" :key="cIndex" :prop="cColumn.key"
  72. :label="cColumn.title">
  73. </el-table-column>
  74. </el-table>
  75. </el-tab-pane>
  76. </el-tabs>
  77. </el-card>
  78. </el-drawer>
  79. </template>
  80. <script>
  81. export default {
  82. name: 'addPriceDeclaration',
  83. data() {
  84. const arr2Obj = function (data, keyName, valueName) {
  85. return Object.fromEntries(
  86. data.map((item) => [item[keyName], item[valueName]])
  87. );
  88. };
  89. const columns = [
  90. { key: "id", title: "id", type: "TagSelect", require: true },
  91. { key: "status", title: "单据状态" },
  92. { key: "priceName", title: "价格名称" },
  93. { key: "supplier", title: "供应商" },
  94. { key: "supplierName", title: "供应商名称" },
  95. { key: "puOrg", title: "采购组织" },
  96. { key: "puOrgName", title: "采购组织名称" },
  97. { key: "currency", title: "币种" },
  98. { key: "currencyName", title: "币种名称" },
  99. { key: "explain", title: "价格合理性说明" },
  100. { key: "buyer", title: "采购员" },
  101. { key: "buyerName", title: "采购员名称" },
  102. { key: "puDept", title: "采购部门" },
  103. { key: "puDeptName", title: "采购部门名称" },
  104. { key: "sourceType", title: "来源单据类型" },
  105. { key: "source", title: "来源单据号" },
  106. { key: "isEffective", title: "是否已推价格" },
  107. { key: "effectiveDate", title: "生效日期" },
  108. { key: "file", title: "附件" },
  109. { key: "tenantId", title: "租户号" },
  110. { key: "revision", title: "乐观锁" },
  111. { key: "createByName", title: "创建人名称" },
  112. { key: "updateByName", title: "更新人" },
  113. { key: "delFlag", title: "删除标记" }
  114. ];
  115. const initColumns = () =>
  116. columns.map((column) => {
  117. const clearable = column.clearable || true;
  118. if (column.type === "InputNumber") {
  119. return {
  120. ...column,
  121. clearable,
  122. config: { controlsPosition: "right" },
  123. };
  124. }
  125. if (column.type === "DatePicker") {
  126. return {
  127. ...column,
  128. clearable,
  129. config: { type: "date" },
  130. };
  131. }
  132. return {
  133. ...column,
  134. clearable,
  135. };
  136. });
  137. const initParams = () => arr2Obj(initColumns(), "key", "value");
  138. // 标签页列
  139. const tabColumns = [
  140. {
  141. key: 'materialBasic',
  142. title: '物料信息表',
  143. tableColumns: [],
  144. },
  145. {
  146. key: 'enforcementScope',
  147. title: '执行范围组织',
  148. tableColumns: [],
  149. },
  150. ]
  151. const initTabColumns = () => tabColumns;
  152. return {
  153. visible: false,
  154. // 主数据表头
  155. columns: initColumns(),
  156. // 表单
  157. params: initParams(),
  158. options: [
  159. {
  160. value: "选项1",
  161. label: "黄金糕",
  162. },
  163. {
  164. value: "选项2",
  165. label: "双皮奶",
  166. },
  167. {
  168. value: "选项3",
  169. label: "蚵仔煎",
  170. },
  171. {
  172. value: "选项4",
  173. label: "龙须面",
  174. },
  175. {
  176. value: "选项5",
  177. label: "北京烤鸭",
  178. },
  179. ],
  180. // 标签页表格列
  181. tabColumns: initTabColumns(),
  182. // 标签页激活
  183. tabName: "materialBasic",
  184. // 标签页对应数据
  185. tabTableDatas: {
  186. materialBasic: [],
  187. enforcementScope: [],
  188. },
  189. }
  190. },
  191. methods: {
  192. setVisible(prop) {
  193. this.visible = prop;
  194. },
  195. handleClose() { },
  196. handleClick() { },
  197. },
  198. created() {
  199. console.log(this.params, this.columns);
  200. },
  201. }
  202. </script>