<commit_before>import $$ from 'slot';
import virtualDom from 'virtual-dom';
import $$tableHints from 'widget/table-hints';
import $$queryObj from '../query-obj';
import config from '../config';
import $$paginator from 'widget/paginator';
import moment from 'moment';
import R from 'ramda';
import paymentRecordStore from 'store/payment-record-store';
import constStore from 'store/const-store';
import $$actionButton from 'widget/action-button';
import overlay from '../overlay';
import $$searchDropdown from 'widget/search-dropdown';
import $$dropdown from 'widget/dropdown';
import accountTermStore from 'store/account-term-store';
import departmentStore from 'store/department-store';
import page from 'page';
import { $$toast } from '../toast';
import object2qs from '../utils/object2qs';

var {
  h
} = virtualDom;

var $$totalCnt = $$(0, 'total-cnt');
var $$loading = $$(false, 'loading');
var $$list = $$([], 'list');
var $$accountTerms = $$([], 'account-terms');
var $$departments = $$([], 'departments');
var $$PAYMENT_RECORD_TYPES = $$({}, 'PAYMENT_RECORD_TYPES');
var $$PAYMENT_RECORD_STATES = $$({}, 'PAYMENT_RECORD_STATES');

var vf = function vf([loading, filters, table, tableHints, paginator]) {
  return h('.list-app' + (loading ? '.loading' : ''), [
    h('.header', [
      h('.title', '扣费记录列表'),
    ]),
    filters,
    table,
    tableHints,
    h('.paginator-container', paginator)
  ]);
};

var filtersVf = function filtersVf(
  [accountTermFilter, departmentDropdown, typeDropdown, statusDropdown]
) {
  return h('.filters', [
    accountTermFilter,
    departmentDropdown,
    typeDropdown,
    statusDropdown,
  ]);
};

var tableVf = function ([PAYMENT_RECORD_STATES, list, ...actionButtons]) {
  return h('table.compact.striped', [
    h('thead', h('tr', [

      h('th', 'id'),
      h('th', '车间'),
      h('th', '金额(元)'),
      h('th', '税金(元)'),
      h('th', '账期'),
      h('th', '创建于'),
      h('th', '状态'),
      h('th', '支付凭证'),
      h('th', '类型'),
      h('th', '操作'),
    ])),
    h('tbody', R.zip(list, actionButtons)
      .map(function ([it, actionButton]) {
        return h('tr', [
          h('td', h('a', {
            href: '/payment-record/' + it.id,
          }, it.id)),
          h('td', it.department.name),
          h('td', String(it.amount)),
          h('td', String(it.tax)),
          h('td', it.accountTerm.name),
          h('td', moment(it.created)
            .format('YY-MM-DD')),
          h('td', R.ifElse(
            R.equals(PAYMENT_RECORD_STATES.REJECTED),
            status => h('span.ca', status),
            R.identity()
          )(it.status)),
          h('td', R.ifElse(
            R.prop('voucherId'),
            paymentRecord => h('a', {
              href: '/voucher/' + paymentRecord.voucherId,
            }, paymentRecord.voucher.number),
            R.always('--')
          )(it)),
          h('td', it.type),
          h('td', actionButton),
        ]);
      })),
  ]);
};

var $$accountTermFilter = $$searchDropdown({
  defaultText: '请选择账期',
  $$value: $$queryObj.map(R.propOr('', 'account_term_id')),
  $$options: $$accountTerms.map(R.map(function (it) {
    return {<commit_msg>in list of payment records, add link to department charge bill<commit_after>import $$ from 'slot';
import virtualDom from 'virtual-dom';
import $$tableHints from 'widget/table-hints';
import $$queryObj from '../query-obj';
import config from '../config';
import $$paginator from 'widget/paginator';
import moment from 'moment';
import R from 'ramda';
import paymentRecordStore from 'store/payment-record-store';
import constStore from 'store/const-store';
import $$actionButton from 'widget/action-button';
import overlay from '../overlay';
import $$searchDropdown from 'widget/search-dropdown';
import $$dropdown from 'widget/dropdown';
import accountTermStore from 'store/account-term-store';
import departmentStore from 'store/department-store';
import page from 'page';
import { $$toast } from '../toast';
import object2qs from '../utils/object2qs';

var {
  h
} = virtualDom;

var $$totalCnt = $$(0, 'total-cnt');
var $$loading = $$(false, 'loading');
var $$list = $$([], 'list');
var $$accountTerms = $$([], 'account-terms');
var $$departments = $$([], 'departments');
var $$PAYMENT_RECORD_TYPES = $$({}, 'PAYMENT_RECORD_TYPES');
var $$PAYMENT_RECORD_STATES = $$({}, 'PAYMENT_RECORD_STATES');

var vf = function vf([loading, filters, table, tableHints, paginator]) {
  return h('.list-app' + (loading ? '.loading' : ''), [
    h('.header', [
      h('.title', '扣费记录列表'),
    ]),
    filters,
    table,
    tableHints,
    h('.paginator-container', paginator)
  ]);
};

var filtersVf = function filtersVf(
  [accountTermFilter, departmentDropdown, typeDropdown, statusDropdown]
) {
  return h('.filters', [
    accountTermFilter,
    departmentDropdown,
    typeDropdown,
    statusDropdown,
  ]);
};

var tableVf = function ([PAYMENT_RECORD_STATES, list, ...actionButtons]) {
  return h('table.compact.striped', [
    h('thead', h('tr', [

      h('th', 'id'),
      h('th', '车间'),
      h('th', '金额(元)'),
      h('th', '税金(元)'),
      h('th', '费用清单'),
      h('th', '账期'),
      h('th', '创建于'),
      h('th', '状态'),
      h('th', '支付凭证'),
      h('th', '类型'),
      h('th', '操作'),
    ])),
    h('tbody', R.zip(list, actionButtons)
      .map(function ([it, actionButton]) {
        return h('tr', [
          h('td', h('a', {
            href: '/payment-record/' + it.id,
          }, it.id)),
          h('td', it.department.name),
          h('td', String(it.amount)),
          h('td', String(it.tax)),
          h('td', h('a', {
            /* eslint-disable max-len */
            href: `/tenant/${it.department.tenant.id}?active_tab_idx=3&active_account_term_id=${it.accountTerm.id}`,
            /* eslint-enable max-len */
            target: '_blank',
          }, '点击查看')),
          h('td', it.accountTerm.name),
          h('td', moment(it.created)
            .format('YY-MM-DD')),
          h('td', R.ifElse(
            R.equals(PAYMENT_RECORD_STATES.REJECTED),
            status => h('span.ca', status),
            R.identity()
          )(it.status)),
          h('td', R.ifElse(
            R.prop('voucherId'),
            paymentRecord => h('a', {
              href: '/voucher/' + paymentRecord.voucherId,
            }, paymentRecord.voucher.number),
            R.always('--')
          )(it)),
          h('td', it.type),
          h('td', actionButton),
        ]);
      })),
  ]);
};

var $$accountTermFilter = $$searchDropdown({
  defaultText: '请选择账期',
  $$value: $$queryObj.map(R.propOr('', 'account_term_id')),
  $$options: $$accountTerms.map(R.map(function (it) {
    return {
{'fraction_non_alphanumeric': 0.20101705055339517, 'fraction_numerical': 0.0010469638049655997, 'mean_word_length': 2.885531667635096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686553', 'n_tokens_mistral': 2279, 'n_tokens_neox': 2278, 'n_words': 473}